David Bloch

David Bloch

  • NA
  • 1
  • 0

TreeView - ForEach statement to return every node/child node that is ticked back to a string

Nov 15 2005 6:04 PM
Hi All

I'm using a TreeView which will display a list of tasks on a ListView similar to the normal Outlook setup. What I'm doing differntly is that I'm using checkboxes

I want each ticked checkbox to return a value to my string - i.e, whatever was in the string before + the new value. 

I also want it to report which level it is being accessed at and what it's parent name is.

I'm doing this on the Event Handler for BeforeCheck/AfterCheck and can't get it to work on either.

Has anyone done this before?  Does anyone have code samples?

Here is what I've tried

private void tvTaskSearch_AfterCheck(object sender, TreeViewEventArgs e)

{

TreeNode objtnAllTasks = new TreeNode();

string isSelected,isSelect;

foreach (TreeNode cb in objtnAllTasks.Nodes)

{

cb

cb.FirstNode

if (cb.Checked)

{

isSelect = cb.Text;

isSelected = " + " + isSelect;

MessageBox.Show(isSelected);

}

}

}