Click here to Skip to main content
15,893,161 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have a datagridview that shows 2 tables data (with left join relation).
i try to add to my form another datagrid of listbox that when i click on the first datagridview i'll see only the rows datagridview match it.

for instance, the 2 tables contain togther:
1 dad "aaaa"
2 dad "bbbb"
3 mom "cccc"
4 boy "ddddd"
5 girl "eeeee"
(i created a datatale in dataset contining those columns)

first datagridview rows shows:
dad
mom
boy
girl

1 dad "aaaa"
2 dad "bbbb"
3 mom "cccc"
4 boy "ddddd"
5 girl "eeeee"

when i click on the first row,
i'll see 3 lines in the oher datagridview or listbox with:
"aaaa"
"bbbb"

What I have tried:

try for hourse the binding tool in visual studio 2017 but i have'nt figure it out yet.
Posted
Updated 11-Feb-18 2:53am
v2

1 solution

2 ways:

  1. DataTable.Select Method (String) (System.Data)[^]
    VB
    Dim firstselection As String = "dad"
    Dim filtereddata = dt.Select("familyfunction='" + firstselection + "'")

  2. Enumerable.Select(TSource, TResult) Method (IEnumerable(TSource), Func(TSource, TResult)) (System.Linq)[^]
    VB
    Dim firstselection As String = "dad" 
    Dim filteredData = dt.AsEnumerable().Where(Function(x) x.Field(Of String)("familyfunction") = firstselection)

 
Share this answer
 
Comments
Member 13672587 11-Feb-18 9:24am    
thanks but can you be more specific.
where to put this lines?
sorry, i'm noob..
i mostly use the wizards in vb17
Maciej Los 11-Feb-18 10:06am    
Let's say, you have got:
- 2 DataGridViews: dgv1 and dv2.
- 1 button: btn1
You have to create btn1_Click event (double click on button). Then add one of above method in that event. Finally: dgv1.DataSource = filteredData

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900