Hi:
I have two combo boxes on screen that when one's selection is change
the
other's items will be updated to reflect the
change
dtMaster = ....
ds.Tables.Add(dtMaster)
dtDetail = ...
ds.Tables.Add(dtBranch)
rel = New DataRelation("MasterDetail", dtMaster.Columns("Code"),
dtDetail.Columns("Code"))
ds.Relations.Add(rel)
cboMaster.DataSource = ds.Tables("Master")
cboMaster.DisplayMember = "Name"
cboMaster.ValueMember = "Code"
cboDetail.DataSource = ds.Tables("Detail")
cboDetail.DisplayMember = "Name"
cboDetail.ValueMember = "Code"
Now, when the user changes the cboMaster, the cboDetail should show
only the record related to the cboMaster, but it show all !
How do i correct this?
Thanks
JCVoon 5 6286
Hi,
Bind the second combobox to a dataview. Filter the results for the
second combobox in the selected value changed event of the first combobox.
Ken
---------------
"JC Voon" <jc*******@yahoo.com> wrote in message
news:41***************@msnews.microsoft.com...
Hi:
I have two combo boxes on screen that when one's selection is change
the
other's items will be updated to reflect the
change
dtMaster = ....
ds.Tables.Add(dtMaster)
dtDetail = ...
ds.Tables.Add(dtBranch)
rel = New DataRelation("MasterDetail", dtMaster.Columns("Code"),
dtDetail.Columns("Code"))
ds.Relations.Add(rel)
cboMaster.DataSource = ds.Tables("Master")
cboMaster.DisplayMember = "Name"
cboMaster.ValueMember = "Code"
cboDetail.DataSource = ds.Tables("Detail")
cboDetail.DisplayMember = "Name"
cboDetail.ValueMember = "Code"
Now, when the user changes the cboMaster, the cboDetail should show
only the record related to the cboMaster, but it show all !
How do i correct this?
Thanks
JCVoon
dtMaster = ....
ds.Tables.Add(dtMaster)
dtDetail = ...
ds.Tables.Add(dtBranch)
rel = New DataRelation("MasterDetail", dtMaster.Columns("Code"),
dtDetail.Columns("Code"))
ds.Relations.Add(rel)
cboMaster.DataSource = ds.Tables("Master")
cboMaster.DisplayMember = "Name"
cboMaster.ValueMember = "Code"
cboDetail.DataSource = ds.Tables("Master")
cboDetail.DisplayMember = "MasterDetail.Name"
cboDetail.ValueMember = "Code"
Ken Tucker: Bind the second combobox to a dataview. Filter the results for the second combobox in the selected value changed event of the first combobox.
Thanks for the reply. It work for me now, but the DataRelation object
become useless, then what is the purposes of the DataRelation object
if we still need to do a lot of code to filter out the record ?
Cheers
JCVoon
Rulin Hong: dtMaster = .... ds.Tables.Add(dtMaster)
dtDetail = ... ds.Tables.Add(dtBranch)
rel = New DataRelation("MasterDetail", dtMaster.Columns("Code"), dtDetail.Columns("Code")) ds.Relations.Add(rel)
cboMaster.DataSource = ds.Tables("Master") cboMaster.DisplayMember = "Name" cboMaster.ValueMember = "Code"
cboDetail.DataSource = ds.Tables("Master") cboDetail.DisplayMember = "MasterDetail.Name" cboDetail.ValueMember = "Code"
Thank for your reply, actually i prefer this method, but my combo box
show "System.Data.DataRowView" in each record in the combo box,
instead of the column value, can u please tell me how to overcome this
problem ?
Thanks
JCVoon
Hi,
If you have 2 datagrids you can have a parent and child grid.
Ken
-------------------
"JC Voon" <jc*******@yahoo.com> wrote in message
news:41**************@msnews.microsoft.com...
Ken Tucker: Bind the second combobox to a dataview. Filter the results for the second combobox in the selected value changed event of the first combobox.
Thanks for the reply. It work for me now, but the DataRelation object
become useless, then what is the purposes of the DataRelation object
if we still need to do a lot of code to filter out the record ?
Cheers
JCVoon This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Joăo Santa Bárbara |
last post by:
Hi all
i have a create a relation between two tables, and both of then have
Autonumbers ( Sql ), since i have the Datarelation, i create a new record in
the master table, and a few in the detail...
|
by: Juan |
last post by:
I built a form that displays a master-detail relation ship, now i need to
add a column to the datagrid displaying the master data, this column
corresponds to the text name of a column stored in the...
|
by: Jane |
last post by:
Hello,
I am working on a windows application with C#. What I need is to display a list of data in 2nd combo box based on the selection of the 1st combo box. I used SqlCommand object and...
|
by: sagdude |
last post by:
I have a master detail datatable and add a relation
DataRelation relation = new DataRelation("PartNoRelation", Dt_Cart.Columns, Tbl_NearestCenters.Columns,false);...
|
by: erniej |
last post by:
as per instructions in the walkthrough, I have managed to
create a master/detail relationship between two datagrids.
However I have a requirement to apply this to three
datagrids and the third...
|
by: Brian Henry |
last post by:
Here's an example of the code.. I have two combo boxes on screen that when
one's selection is change the other's items will be updated to reflect the
change (based on a relation)
Private...
|
by: SoftWhiteDelgiht |
last post by:
Help me. I am obviously stupid! :-)
I am just starting out with VB.Net and am trying to do a simple master/detail form with a SqlServer backend.
I have created a combo box which is to populate with...
|
by: Patrick |
last post by:
Hi - I have a master/detail form with a combo box (AssetCode) on the
master form which uses a query as its Row Source. I can choose a
selection from the AssetCode combo box which fires an...
|
by: fstenoughsnoopy |
last post by:
Ok the complete story. I have a Contact Table, Query and Form, that
are used to input
and store the contact info for customers. They have FirstName, LastName
and Address as the primary key...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
|
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...
| |