Treeview: Added/New Nodes not showing up during run-time

L

LordHog

Hello,

I am having a problem with the Treeview control in Visual Studio.NET
2005. I have a treeview control which has two root trees and by default
two child nodes indicating no items have been added to the two root
nodes.

During run-time I need to add information under either one of the two
root nodes, but when the nodes are added they are not displayed/shown
in the treeview. During debugging the node count is correct for the
added nodes, but they are not displayed.

Here is the code which I am having problems with

// These are the declared members
System.Windows.Forms.TreeNode SymbolsNode;
System.Windows.Forms.TreeNode ScriptVariablesNode;
System.Windows.Forms.TreeNode NoSymbolsLoaded;
System.Windows.Forms.TreeNode NoScriptVariablesLoaded;

// called from the C'tor
private void InitComponents()
{
SymbolsNode = new SWF.TreeNode( "Symbols" );
ScriptVariablesNode = new SWF.TreeNode( "Script Variables" );
NoSymbolsLoaded = new SWF.TreeNode( "No Symbols Loaded" );
NoScriptVariablesLoaded = new SWF.TreeNode( "No Script Variables
Defined" );

tvSymbols.Nodes.Add( SymbolsNode );
tvSymbols.Nodes.Add( ScriptVariablesNode );

ClearSymbols();
ClearScriptVariables();
}

public void ClearSymbols( )
{
SymbolsNode.Nodes.Clear();
SymbolsNode.Nodes.Add( NoSymbolsLoaded );
SymbolsNodeCleared = true;
}


public void LoadSymbols( SymbolDef[] symbols )
{
// Note: SymbolDef is a structure that contains a string and UInt32

try
{
tvSymbols.BeginUpdate();
MessageBox.Show( tvSymbols.GetNodeCount( true ).ToString() );

if ( SymbolsNodeCleared )
{
SymbolsNode.Nodes.Clear();
SymbolsNodeCleared = false;
}

foreach ( SymbolDef sym in symbols )
{
SymbolsNode.Nodes.Add(
new SWF.TreeNode( sym.SymbolName + "(0x" + sym.Address + ")"
) );
}

tvSymbols.EndUpdate();
MessageBox.Show( tvSymbols.GetNodeCount( true ).ToString() );
}
catch( Exception e )
{
MessageBox.Show( e.Message );
}
}

As the code runs, the messagebox are showing the correct values, but I
can't figure out how to display the child nodes. Do I need to register
for an event and enable or validate a signal? Any help is greatly
appreciated as my head hurts from banging it on my desk.

Mark
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top