Bindingsource Filter show all rows

muro

Active member
Joined
Apr 30, 2018
Messages
26
Programming Experience
3-5
Hello dear friends,

I have 2 Tables which are related to each, i made the relationship in the dataset xsd window. When selecting a row in the parent table all child rows are shown and it works perfect. However when i filter the bindingsource only the current selected parent rows child rows are shown. how can i show all rows of the childtable ? This is my code
C#:
private void textBox1_TextChanged(object sender, EventArgs e)
        {
            kategorieartikelBindingSource.Filter =  $"CONVERT(Artikelnummer,System.String) Like '{textBox1.Text}%'";
        }
2.gif
 
If you have bound the child BindingSource to the parent BindingSource then you can't. You would need to bind the child BindingSource to the child DataTable, which means that you will also have to filter by parent manually.
 
Thank you sir for the advice i am glad you responded. Would i do that at runtime, and how? Can you explain some more.
 
If you have set up the bindings in the designer then you need to do it through the Properties window. Take a look at how the parent BindingSource is bound to the parent DataTable and then bind the child BindingSource the same way to the child DataTable. You will then need to handle the appropriate event for when a parent row is selected, i.e. CurrentChanged for the parent BindingSource, and then set the Filter of the child BindingSource to filter by parent ID.
 

Latest posts

Back
Top Bottom