تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
[VB.NET] ربط 2 DataGridView ببعض
#1
السلام عليكم

عندي 2 DataGridView المطلوب طريقة ربطهم مع بعض بحيث اختار من الأول اسم الشخص ويظهر في الثاني كل ارقامه

ولكم جزيل الشكر
الرد }}}
تم الشكر بواسطة:
#2
اشكرك على الرد

انا لدي كود ولكنه يفرض علي الشكل حاولت التخلص من التقييد الذي يفرضه الكود ولكن لم استطع
لدي 2 داتا قريد فيو ولكنه يتجاهلها تماماً

Private masterDataGridView As New DataGridView()
Private masterBindingSource As New BindingSource()
Private detailsDataGridView As New DataGridView()
Private detailsBindingSource As New BindingSource()

<STAThreadAttribute()>
Public Shared Sub Main()
Application.Run(New frmMain())
End Sub

' Initializes the form.
Public Sub New()

masterDataGridView.Dock = DockStyle.Fill
detailsDataGridView.Dock = DockStyle.Fill

Dim splitContainer1 As New SplitContainer()
splitContainer1.Dock = DockStyle.Fill
splitContainer1.Orientation = Orientation.Horizontal
splitContainer1.Panel1.Controls.Add(masterDataGridView)
splitContainer1.Panel2.Controls.Add(detailsDataGridView)

Me.Controls.Add(splitContainer1)
Me.Text = "DataGridView master/detail demo"

End Sub
Private Sub GetData()

Try

' Create a DataSet.
Dim data As New DataSet()
data.Locale = System.Globalization.CultureInfo.InvariantCulture

' Add data from the Customers table to the DataSet.
Dim masterDataAdapter As New OleDbDataAdapter("select * from tblNames", Conn)
masterDataAdapter.Fill(data, "tblNames")

' Add data from the Orders table to the DataSet.
Dim detailsDataAdapter As New OleDbDataAdapter("select * from Numbers", Conn)
detailsDataAdapter.Fill(data, "Numbers")

' Establish a relationship between the two tables.
Dim relation As New DataRelation("tblNamesNumbers",
data.Tables("tblNames").Columns("ID"),
data.Tables("Numbers").Columns("NameID"))
data.Relations.Add(relation)

' Bind the master data connector to the Customers table.
masterBindingSource.DataSource = data
masterBindingSource.DataMember = "tblNames"

' Bind the details data connector to the master data connector,
' using the DataRelation name to filter the information in the
' details table based on the current row in the master table.
detailsBindingSource.DataSource = masterBindingSource
detailsBindingSource.DataMember = "tblNamesNumbers"
Catch ex As Exception
MessageBox.Show("To run this example, replace the value of the " &
"connectionString variable with a connection string that is " &
"valid for your system.")
End Try

End Sub

Private Sub frmMain_Load(sender As Object, e As EventArgs) Handles MyBase.Load
' Bind the DataGridView controls to the BindingSource
' components and load the data from the database.
masterDataGridView.DataSource = masterBindingSource
detailsDataGridView.DataSource = detailsBindingSource
GetData()

' Resize the master DataGridView columns to fit the newly loaded data.
masterDataGridView.AutoResizeColumns()

' Configure the details DataGridView so that its columns automatically
' adjust their widths when the data changes.
detailsDataGridView.AutoSizeColumnsMode =
DataGridViewAutoSizeColumnsMode.AllCells

End Sub
الرد }}}
تم الشكر بواسطة:
#3
أخي الفاضل :

أعددت لك مثال بسيط بالمرفقات

عند الضغط Double Click على الصف المطلوب ... تظهر باقي البيانات في DataGridView آخر

أتمنى أن يساعدك هذا المثال


وفقنا الله واياكم


الملفات المرفقة
.rar   DGV_MD.rar (الحجم : 75.67 ك ب / التحميلات : 113)
Don't Be The Perfect one
be the right one
الرد }}}
تم الشكر بواسطة: khodor1985


المواضيع المحتمل أن تكون متشابهة .
الموضوع : الكاتب الردود : المشاهدات : آخر رد
  تعديل بيانات عمود DataGridView دفعة واحدة مصمم هاوي 2 164 05-03-24, 08:27 PM
آخر رد: مصمم هاوي
  فلترة datagridview بدون قاعدة بيانات صالح عبدالله 3 295 02-02-24, 04:07 PM
آخر رد: صالح عبدالله
  [VB.NET] ظهور التاريخ غير مرتب بالأقدم في datagridview مبرمج صغير 1 4 304 26-01-24, 03:41 PM
آخر رد: atefkhalf2004
  [VB.NET] التاريخ في أداة أبو سامر لطباعة DataGridView مبرمج صغير 1 17 629 26-01-24, 01:52 AM
آخر رد: مبرمج صغير 1
  مشكلة في datagridview Adata 4 310 17-01-24, 03:00 PM
آخر رد: aljzazy
Lightbulb [VB.NET] إطهار الصورة بمقاس معين في DataGridView أبو خالد الشكري 2 323 14-12-23, 03:01 PM
آخر رد: أبو خالد الشكري
Question [VB.NET] اسم عمود الأرقام في DataGridView أبو خالد الشكري 6 606 03-12-23, 08:01 AM
آخر رد: أبو خالد الشكري
  [VB.NET] Datagridview Slow حركة بطيئة waataanys 1 294 20-11-23, 04:33 PM
آخر رد: justforit
Heart [سؤال] ♥ إعادة ترتيب صفوف DataGridView ♥ أبو خالد الشكري 2 304 24-09-23, 08:50 AM
آخر رد: أبو خالد الشكري
  كيف الحصول على قيمة الخلية بعد تحديد الصف في datagridview؟ hazim1 2 558 06-08-23, 01:12 AM
آخر رد: hazim1

التنقل السريع :


يقوم بقرائة الموضوع: بالاضافة الى ( 1 ) ضيف كريم