473,405 Members | 2,300 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

How do I use a combobox for master-detail binding with a datagrid?

I have a combobox that is populated with a list of names. When a name is
selected I want to populate a datagrid with name information. I have my
master-detail defined in my dataset and it works fine if I use a datagrid
for the master, instead of a combobox. But the combobox won't cause the
repopulation of the datagrid with the appropriate data. What's the trick?

TIA,

Larry Woods
cross-posted on ...dotnet.languages.vb.controls
Nov 21 '05 #1
1 1993
Hi,

Create a dataview to for the datagrid. Bind the datagrid to the
dataview. Filter the records in the combobox selected item changed event.

Dim ds As New DataSet

Dim dv As DataView

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Dim strConn As String

Dim strSQL As String

Dim da, daOrders As OleDbDataAdapter

Dim conn As OleDbConnection

strConn = "Provider = Microsoft.Jet.OLEDB.4.0;"

strConn &= "Data Source = Northwind.mdb;"

conn = New OleDbConnection(strConn)

da = New OleDbDataAdapter("Select * From Customers", conn)

da.Fill(ds, "Customers")

daOrders = New OleDbDataAdapter("Select * From Orders", conn)

daOrders.Fill(ds, "Orders")

dv = New DataView(ds.Tables("Orders"))

ComboBox1.DataSource = ds.Tables("Customers")

ComboBox1.DisplayMember = "CustomerID"

DataGrid1.DataSource = dv

End Sub

Private Sub ComboBox1_SelectedValueChanged(ByVal sender As Object, ByVal e
As System.EventArgs) Handles ComboBox1.SelectedValueChanged

Dim drv As DataRowView

Try

drv = DirectCast(ComboBox1.SelectedItem, DataRowView)

dv.RowFilter = "CustomerID = '" & drv.Item("CustomerID").ToString & "'"

Catch ex As Exception

End Try

End Sub

Ken
----------------------
"Larry Woods" <la***@NOSPAMlwoods.com> wrote in message
news:uy*************@TK2MSFTNGP11.phx.gbl...
I have a combobox that is populated with a list of names. When a name is
selected I want to populate a datagrid with name information. I have my
master-detail defined in my dataset and it works fine if I use a datagrid
for the master, instead of a combobox. But the combobox won't cause the
repopulation of the datagrid with the appropriate data. What's the trick?

TIA,

Larry Woods
cross-posted on ...dotnet.languages.vb.controls

Nov 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: Mr. B | last post by:
Here's the situation... You've a combobox with Items already added. Say they look like this (or even lines of text): 10-00-232 10-00-256 10-01-006 10-01-213 10-02-200
4
by: Chandra | last post by:
Hello Sir, This is Chandra and Working as Software Engineer. I got a really weird problem with ComboBoxes. I have set the ComboBox DroppedDown Property to true. Now the actual problem is...
7
by: Nicolae Fieraru | last post by:
Hi All, I am trying to change the rowsource of a combobox when I click on it. I played with many events, associated with the form and the combobox, but still haven't figured out what is the way...
8
by: Zlatko Matię | last post by:
There is a form (single form) and a combobox. I want that current record of the form is adjusted according to selected value in the combobox. Cuurrent record should be the same as the value in the...
5
by: Mika M | last post by:
Hello! I have Windows Forms application form containing TextBoxes, six ComboBoxes, and DataGrid for details. I have created DataSet with needed tables, and created relations between tables, and...
2
by: Don | last post by:
I've looked high and low for some code that will allow me to have a combobox with a flat borderstyle. I found a few examples, but nothing that was really usable for me. I had the following...
3
by: Mark | last post by:
I have a bug with combobox which is reproduced by the following steps: Create a form with a Tabcontrol and two tabs. On one tab place a combo box and give it the entries one, two and three....
1
by: polocar | last post by:
Ciao a tutti, leggendo qua e lą per il forum ho scoperto che non sono l'unico ad avere questo problema. Se si inserisce un controllo ComboBox in un form di C#, non č possibile impostare la sua...
1
by: exxcusemee | last post by:
Hi to all, Basically my problem is that that i am trying to set the value of combobox.But problem is i dont have value of combobox.Whatever i have is the label which will render to the user...
5
by: shiwawa | last post by:
I have a problem filtering records in my subform using a ComboBox in the Main Form. I have tried options proferred in other forums and have still not git the desired result. I know I must be missing...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.