.NET Logo
Welcome Guest Search | Active Topics | Members | Log In | Register

เพิ่มข้อมูล dataGridView Options · View
ตุ๊กตา
Posted: Friday, July 25, 2008 1:54:12 PM
Rank: มืออาชีพ
Groups: Member

Joined: 12/11/2007
Posts: 30
Location: thai
อาจารย์ พี่ๆ ช่วยแนะหน่อยค่ะ
เมื่อเรา double click ข้อมูลที่อยู่ใน  dataGridView1 แล้ว อยากให้ข้อมูลที่double click ใน dataGridView1
ไปเพิ่ม ใน dataGridView2
เขียนยังไงค่ะ


ตุ๊กตา attached the following image(s):
untitled.JPG

zerozaaa
Posted: Monday, July 28, 2008 1:03:52 AM
Rank: มือพระกาฬ
Groups: Member

Joined: 6/13/2008
Posts: 79

ส่วนตัวผมคิดว่า น่าจะสร้าง Table ชั่วคราว ไว้รับ จากการคลิกจาก Gridview1 แล้วส่งไป Gridview2 น่ะคับ

ngo_somc
Posted: Tuesday, July 29, 2008 2:53:25 PM
Rank: มือฝึกหัด
Groups: Member

Joined: 7/7/2008
Posts: 9
Location: Thai

เวลาที่ double click ที่ grid จะได้ datarows มาด้วยนะครับ

ฉะนั้นแล้วเราก็สร้างdatatable ขึ้นมารับ datarows ที่ได้จากการ double click น่ะครับ แล้วก็นำไปใช้กับ grid2 ได้เลยครับ

ดังตัวอย่างนี้ (ผมไม่ได้ copy มานะครับ  มันอาจจะผิด syntax บ้าง ก็แก้เอาละกันครับ)

 

private datarow dr = new datarow();

ไปเขียนที่ event doubleClick ของ Grid1 :

dr = grid1.selectrows[0];

แล้วก็ไปเขียนฟังก์ชันข้างนอก :

DataTable dt = new DataTable();

dt.Rows.add(dr);

 

ทีนี้ก็เอาไปใช้ได้เลย :

grid2.Datasource = dt;

 

เสร็จแล้วมั้งครับ  ลองดูนะครับ  คงจะใกล้เคียงอยู่บ้าง  อิอิ

 

ตุ๊กตา
Posted: Wednesday, July 30, 2008 4:18:42 PM
Rank: มืออาชีพ
Groups: Member

Joined: 12/11/2007
Posts: 30
Location: thai

ขอบคุณนะค่ะสำหรับคำแนะนำ เด๋วไปลองทำดู

Users browsing this topic
Guest


Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Main Forum RSS : RSS

YAFVision Theme Created by Jaben Cargman (Tiny Gecko)
Powered by Yet Another Forum.net version 1.9.1.8 (NET v2.0) - 3/29/2008
Copyright © 2003-2008 Yet Another Forum.net. All rights reserved.


Sponsored by