تقييم الموضوع :
  • 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 ك ب / التحميلات : 121)
Don't Be The Perfect one
be the right one
الرد }}}
تم الشكر بواسطة: khodor1985


المواضيع المحتمل أن تكون متشابهة .
الموضوع : الكاتب الردود : المشاهدات : آخر رد
  [VB.NET] محتاج اربط DataGridView بزر بحث bakrycold 1 552 28-02-25, 12:11 AM
آخر رد: bakrycold
  [VB.NET] استعراض بيانات في Datagridview واضافة جميع البيانات لجدول محدد sql skode 0 489 12-01-25, 12:50 AM
آخر رد: skode
Information [VB.NET] تنسيق أعمدة DataGridView أبو خالد الشكري 3 581 21-12-24, 02:40 PM
آخر رد: aljzazy
  هل يوجد كود لعدم تكرار نفس البيانات ببعض الحقول F.H.M 19 902 15-09-24, 06:14 AM
آخر رد: F.H.M
Exclamation [VB.NET] اريد كود لتصدير البيانات من DataGridView الى ملف Excel zazasami 1 497 04-08-24, 09:15 PM
آخر رد: mrfenix93
  تعديل بيانات عمود DataGridView دفعة واحدة مصمم هاوي 2 691 05-03-24, 08:27 PM
آخر رد: مصمم هاوي
  فلترة datagridview بدون قاعدة بيانات صالح عبدالله 3 685 02-02-24, 04:07 PM
آخر رد: صالح عبدالله
  [VB.NET] ظهور التاريخ غير مرتب بالأقدم في datagridview مبرمج صغير 1 4 867 26-01-24, 03:41 PM
آخر رد: atefkhalf2004
  [VB.NET] التاريخ في أداة أبو سامر لطباعة DataGridView مبرمج صغير 1 17 1,534 26-01-24, 01:52 AM
آخر رد: مبرمج صغير 1
  مشكلة في datagridview Adata 4 714 17-01-24, 03:00 PM
آخر رد: aljzazy

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


يقوم بقرائة الموضوع: