c# - How to make a specific Tree Node to appear as a folder in a Tree View -
how make specific tree node appear folder in tree view? creating dynamic tree view using table in database , based on 1 column i.e., nodetype having value (1 or 2), want either appear folder or normal tree node.
pseudo code more beneficial.
thanks in advance!
you can put folder image in imagelist control , set imagelist property of treeview control imagelist , when creating nodes set imageindex of node desired index.
treenode tn = new treenode(); if (imageshouldbefolderimage) tn.imageindex = 0; // if want show image other cases, // if want no image ignore else part else tn.imageindex = 1;
update:
if selecting node changes it's image undesirable image it's caused treeview's selectedimageindex property, suggest adding empty image imagelist , set nodes selectedimageindex.
treenode tn = new treenode(); if (imageshouldbefolderimage) { tn.imageindex = 0; tn.selectedimageindex = 0; } else { tn.imageindex = 1;//the index of empty image tn.selectedimageindex = 1; }
Comments
Post a Comment