How to Disply the subItems in a ComboBox

jeeban.nist

Member
Joined
Jan 28, 2008
Messages
5
Programming Experience
1-3
hi
i m using vb.net 2005.
i am displaying the data in a combo box from a table (MS ACESS).
but i have to display the subitems of data from the another table...
how can i display .
 
Last edited:
Are you saying, without actually saying, that you want multiple columns in your ComboBox? Or are you saying, without actually saying, that you want to filter some other list based on the selection in the ComboBox. Please be clear about exactly what you want.
 
Actually i have to display the Items From Item tables and subItems from the SubItems table . The ItemID is the PK and SubItem ID refers to the ItemID.


In comboBox , i suppose to display like as follows

VB.NET:
Item1
     SubItems1
     SubItems 2
Item2
     SubItems3
     SubItems4
Items3
     SubItem5
Items4...
 
Last edited by a moderator:
So you're saying you only want one column but you want the data to come from more than one table? In that case you just won't be able to use data-binding. Your going to have to loop through the items and add them yourself. Assuming that both tables are in the same DataSet and you have created a DataRelation between them then you can call the GetChildRows of each parent row to get its child rows, e.g.
VB.NET:
For Each parentRow As DataRow In parentTable
    'Use parentRow here.

    For Each childRow As DataRow In parentRow.GetChildRows("ParentChildRelation")
        'Use childRow here.
    Next childRow
Next parentRow
 
Actually i have to display the Items From Item tables and subItems from the SubItems table . The ItemID is the PK and SubItem ID refers to the ItemID.


In comboBox , i suppose to display like as follows

Item1
----SubItems1
----SubItems 2
Item2
----SubItems3
----SubItems4
Items3
----SubItem5
Items4...
 
Since that resembles so much a tree have you considered using a TreeView control?
 
Back
Top