bindingSource question ?

  • Thread starter Thread starter mateo
  • Start date Start date
M

mateo

Hello i have two tables (Groups and Users) bound each one to a
BindingSource like this

this._bindingEntrepriseGrp.DataSource = MyDataSource;
this._bindingEntrepriseGrp.DataMember = "CustomerGroups";
this._bindingEntrepriseUsr.DataSource = this._bindingEntrepriseGrp;
this._bindingEntrepriseUsr.DataMember = "CustomerGroups_CustomerUsers";



I'm bouding the second one (Users) with a relation to the first one
named "CustomerGroups_CustomerUsers"


Now the groups are shown in a TreeView that i populate myself
recursively keeping in the Tag of each TreeNode the corresponding
DataRow. Users are shown in a DataGridView. when the selected TreeNode
change i must show all users belonging to this group in the
DataGridView. I tried something like this


this._bindingEntrepriseGrp.Position =
this._bindingEntrepriseGrp.IndexOf(dr);


where dr is the DataRow stored in the Tag property of the
selectedTreeNode but nothing happen??
What is wrong ?


Also, Is there a way of addind manually sone rows to the DataGridView
(cause i must show all child groups of the selected group in the the
grid)??


Thanks in advance
mateo
 
Hi Mateo
You can use Filter property of BindingSource.Assume you store datarow
of CustomerGroups in TreeNode's Tag property, you can write the
following code snippet into TreeView's AfterClick

DataRow dr=(DataRow)treeView1.SelectedNode;
int groupID=(int)dr["groupID"];

this._bindingEntrepriseUsr.Filter="GroupID="+groupID.ToString();

I hope this helps,
A.Hadi
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top