Hello experts,
I can't seem to figure out why my treeview node fails to update
itself. That is, to retain only one node at a time.
I am trying to emulate mySql's Query Browser's History tab. Every time
a user executes a valid sql command string, this command gets saved to
a date text file (like a csv file), and then pulls it out again. If a
node (a date string) matches your current system date, that date node
gets expanded. Here's my code:
string strActiveDate = Utils.lookForDateMatch(ref
HistoryFilesBag);
TreeNode n = getNodeByText(ref tvHistory,
strActiveDate, true);
if (n != null)
{
tvHistory.SelectedNode = n;
tvHistory.SelectedNode.Expand(); // <--
problem here
}
else
{
tvHistory.SelectedNode = null;
}
The problem shows up when, for example, you double-click a command
from one of the nodes, the command
string shows up on the textbox, and then when you click the "Execute"
button, the tree node from which you obtained the command string
*collapses*. I need it expanded. What do I do? I've tried the
treeview.BeginUpdate() and treeview.EndUpdate() pair, the Invalidate()
and Refresh() but still no go. :(
Any suggestions?