Click here to Skip to main content
16,005,339 members
Home / Discussions / C#
   

C#

 
AnswerRe: How to clear selected items from multiple checkedlistboxes Pin
Nick Parker30-Aug-04 9:27
protectorNick Parker30-Aug-04 9:27 
AnswerRe: How to clear selected items from multiple checkedlistboxes Pin
Heath Stewart30-Aug-04 9:47
protectorHeath Stewart30-Aug-04 9:47 
GeneralRe: ISA bus access Pin
Dave Kreskowiak30-Aug-04 7:47
mveDave Kreskowiak30-Aug-04 7:47 
Generalget drive roots Pin
fire.fox30-Aug-04 7:36
fire.fox30-Aug-04 7:36 
GeneralRe: get drive roots Pin
Heath Stewart30-Aug-04 8:10
protectorHeath Stewart30-Aug-04 8:10 
GeneralRe: get drive roots Pin
leppie30-Aug-04 22:23
leppie30-Aug-04 22:23 
GeneralRe: get drive roots Pin
Heath Stewart31-Aug-04 6:15
protectorHeath Stewart31-Aug-04 6:15 
Generalpopulate treeview with dataset Pin
Anonymous30-Aug-04 7:01
Anonymous30-Aug-04 7:01 
Does anybody know any example code of populating windows treeview control with hierarchical dataset?

I prefer C# but vb will also do it.

I found couple samples on this side, but one uses classes, and another delegate. Both seem overkill.

My hierarchy is 3 levels deep, and the number of rows are limited. I can afford to load the treeview at the form load time.

I have been putting together following pieces, but it failed to load the tree in the relationship I want.

Thanks for any help!

private void Form1_Load(object sender, System.EventArgs e)
{
string sSQL;
SqlCommand cmd = sqlCnPubs.CreateCommand();
cmd.CommandType=CommandType.Text ;
sSQL = "Select ID, Segment from Prod_Segments";
cmd.CommandText=sSQL;
SqlDataAdapter daSeg = new SqlDataAdapter();
daSeg.SelectCommand=cmd;
DataSet dsProd=new DataSet();
daSeg.Fill (dsProd, "Segments");
sSQL = "Select ID, Catagory, SegmentID from Prod_Catagories";
cmd.CommandText=sSQL;
SqlDataAdapter daCat = new SqlDataAdapter();
daCat.SelectCommand=cmd;
DataSet dsCatagories=new DataSet();
daCat.Fill (dsProd, "Catagories");
dsProd.Relations.Add("SegtoCat", dsProd.Tables["Segments"].Columns["ID"], dsProd.Tables["Catagories"].Columns["SegmentID"]);

foreach (DataRow rowSeg in dsProd.Tables["Segments"].Rows)
{
TreeNode nodeSeg = new TreeNode();
nodeSeg.Text=rowSeg["Segment"].ToString();
nodeSeg.ImageIndex=0;
tvwProd.Nodes.Add(nodeSeg);
foreach (DataRow rowCat in rowSeg.GetChildRows("SegtoCat"))
{
TreeNode nodeCat = new TreeNode();
nodeCat.Text=rowCat["Catagory"].ToString();
tvwProd.Nodes.Add(nodeCat);
}
}

GeneralRe: populate treeview with dataset Pin
Heath Stewart30-Aug-04 7:49
protectorHeath Stewart30-Aug-04 7:49 
QuestionCan apple ArrayList in string[] Pin
arbrsoft30-Aug-04 6:57
arbrsoft30-Aug-04 6:57 
AnswerRe: Can apple ArrayList in string[] Pin
Judah Gabriel Himango30-Aug-04 7:02
sponsorJudah Gabriel Himango30-Aug-04 7:02 
GeneralNested UserControls Pin
Den2Fly30-Aug-04 6:16
Den2Fly30-Aug-04 6:16 
GeneralRe: Nested UserControls Pin
Charlie Williams30-Aug-04 6:24
Charlie Williams30-Aug-04 6:24 
GeneralRe: Nested UserControls Pin
Nick Parker30-Aug-04 6:25
protectorNick Parker30-Aug-04 6:25 
QuestionHas anyone attempted synchronized scolling? Pin
LongRange.Shooter30-Aug-04 6:12
LongRange.Shooter30-Aug-04 6:12 
AnswerRe: Has anyone attempted synchronized scolling? Pin
Heath Stewart30-Aug-04 7:34
protectorHeath Stewart30-Aug-04 7:34 
GeneralRe: Has anyone attempted synchronized scolling? Pin
LongRange.Shooter31-Aug-04 6:50
LongRange.Shooter31-Aug-04 6:50 
GeneralRe: Has anyone attempted synchronized scolling? Pin
progload3-Oct-04 10:21
progload3-Oct-04 10:21 
GeneralErrorProvider() Not Displayed Pin
dbetting30-Aug-04 5:36
dbetting30-Aug-04 5:36 
Generalinstalling global cbt hooks in c# Pin
vignesh_s30-Aug-04 3:51
vignesh_s30-Aug-04 3:51 
GeneralRe: installing global cbt hooks in c# Pin
Nick Parker30-Aug-04 4:15
protectorNick Parker30-Aug-04 4:15 
GeneralRe: installing global cbt hooks in c# Pin
Duncan Edwards Jones30-Aug-04 4:15
professionalDuncan Edwards Jones30-Aug-04 4:15 
GeneralRe: installing global cbt hooks in c# Pin
vignesh_s3-Sep-04 3:40
vignesh_s3-Sep-04 3:40 
Generalset time in c# Pin
erina54830-Aug-04 3:14
erina54830-Aug-04 3:14 
GeneralRe: set time in c# Pin
Nick Parker30-Aug-04 4:27
protectorNick Parker30-Aug-04 4:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.