Click here to Skip to main content
15,886,137 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Well for example, I have a table named Country and it has two columns Country name and city name, in column 'country name' i have name of different countries and in column 'city name' I have name of cities. If the value in country name column is USA than the value in city name column will be any city of USA not anything else, the table is structured that way. So now I want to bind treeview with this table like parent node should be Country (node, 0) and on clicking country its child should be country name and then on clicking or collapsing any country, list of its cities should appear, like this,

-Country
- USA
-New York
-Washington
- Australia
-Sydney
-Melbourne

means to add child nodes (cities) against their respective country name. How can i achieve this in windows form using vb.net. Please can anyone help?
Posted
Updated 20-Jan-14 11:17am
v2

select city from Country where country = @country

will get you the data you want.

select country, city from Country order by country

will get you the data in order so you can build a tree view, jumping to a new node when the country name changes.


You have not indicated if you're using web or windows, winforms or WPF, ASP.NET or MVC, so it's really hard to give any more info than that.


This[^] article shows how to bind XML to a tree view, that seems like the logical format to use, and you can write SQL to return it.
 
Share this answer
 
v2
Comments
Member 10536862 20-Jan-14 17:24pm    
I am using windows form and i am getting the vluea in a method using these queries the problem i am facing is that these values are not binding as nodes.
Christian Graus 20-Jan-14 17:43pm    
The problem I have is that you're not posting the code where you're trying to do this. The information you provided, is apparently about the bit you knew how to do. What does your code look like ? What is happening ? Is there an error message?
DEAR SIR,

I HAVE A SQL TABLE AND FIELDS ARE FORMANME, FORMVAL BIT , AND THREE ANOTHER FIELDS THAT HAVE ONLY VAL IN BIT

AND NOW I WANT TO LOAD THESE VALUE IN TREEVIEW IN VB.NET2008 SP1

LIKE AS
FIRST TREE NODE IS MODULE AND WHEN I CLICK MODULE THEN LOAD FORM NAME IN PARENT OF MODULE NODE AND TREEVIEW CHECKBOX IS ENABLED AS WELL AS I ALSO WANT TO CHECKED SAME FORMNAME FROM THEIR FORM VALUE AND OTHER THREE FIELDS ARE WANT TO ADD UNDER FORMNAME NODE WITH NAME OF TABLE FIELD NAME AND CHECKED FROM THEIR VALUE.

if this is on adodb connection then well if no then i will try on yours suggestion

I HAVE TRY MANY TIMES BUT NO SOLUTION GET.

SO PLEASE HELP ANYBODY FROM THIS TOPIC.



Thanks
Kamal
 
Share this answer
 

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