sormv
asked on
storing ID's of a tree node
Hi,
I am having a XML File, and contains databse name,id, table names,table ids, field names,ids. I am populating a tree from this data like,
Database1
| _ Table1
|_Field1
|_Field2
|-Field3
|_Table2
|_ Field21
|_ Field22
|_ Field23
|_ Table3
|_Field31
|_Field32
|_Field33
user can select and add fileds from tree to a listview or he can drag drop fields from tree to listview.Depending on the user selected fields, I am stroring field IDS now.
I need to store the Table ID's also. I have to use thses ID's in creating a SQL statement dynamically.
User can select one or more fields from each table and I need to store distinct table ID's.
I implemeted all the functionality except storing table ID's.
Any Ideas!!
Thanks In Advance.
I am having a XML File, and contains databse name,id, table names,table ids, field names,ids. I am populating a tree from this data like,
Database1
| _ Table1
|_Field1
|_Field2
|-Field3
|_Table2
|_ Field21
|_ Field22
|_ Field23
|_ Table3
|_Field31
|_Field32
|_Field33
user can select and add fileds from tree to a listview or he can drag drop fields from tree to listview.Depending on the user selected fields, I am stroring field IDS now.
I need to store the Table ID's also. I have to use thses ID's in creating a SQL statement dynamically.
User can select one or more fields from each table and I need to store distinct table ID's.
I implemeted all the functionality except storing table ID's.
Any Ideas!!
Thanks In Advance.
You have a property called "Tag" in the TreeNode object in WinForms, just use it to store the table Ids for Table Nodes, and fetch it from the selection when creating your sql statement.
ASKER
Hi Kiwi,
I am using Tag property of treenode for setting the table id's. But if you select multiple field id's from the same table u will be having same table id with multiple times.I need to have distinct table id's for the user selected fields from different tables.
Is there is any way, I can store table id's in a array and I can select distinct table IDs from that.
Thanks.
I am using Tag property of treenode for setting the table id's. But if you select multiple field id's from the same table u will be having same table id with multiple times.I need to have distinct table id's for the user selected fields from different tables.
Is there is any way, I can store table id's in a array and I can select distinct table IDs from that.
Thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Sorry for the response delay.
Here is what you have:
- First step, You can point to the tree nodes of the original treenode in your listview (still this Tag property).
- Second step, you have the field id in your treenode (Tag).
- Finally, you have the table name in the table treenode (Tag).
Now what you can do:
In the field treenode, you have a Parent property pointing to the parent node in the treenode.
So all you have to do is: ((TreeNode) myListViewItem.Tag).Parent .Tag, and you will have the treenode.
If this does not work, Tag contains an object, so why not create a class, like :
struct MyField
{
string tableName;
string fieldName;
}
and put it in the Tag of your treenodes.
Cheers,
Julien
Here is what you have:
- First step, You can point to the tree nodes of the original treenode in your listview (still this Tag property).
- Second step, you have the field id in your treenode (Tag).
- Finally, you have the table name in the table treenode (Tag).
Now what you can do:
In the field treenode, you have a Parent property pointing to the parent node in the treenode.
So all you have to do is: ((TreeNode) myListViewItem.Tag).Parent
If this does not work, Tag contains an object, so why not create a class, like :
struct MyField
{
string tableName;
string fieldName;
}
and put it in the Tag of your treenodes.
Cheers,
Julien