It seems to me that on each "execute" you are clearing the Tree and filling it again. Then you try to select the same node again.
If above is correct then make sure that you are expanding the node "after" re-filling the Tree. Or maybe you should provide more code for a better idea. On Mon, Jul 27, 2009 at 7:06 AM, Benj Nunez <[email protected]> wrote: > > I also tried this line: > > tvHistory.SelectedNode.Toggle(); > > > It still doesn't let me expand the node. Anyone? > > > > > Benj > > > > On Jul 25, 2:30 am, Benj Nunez <[email protected]> wrote: > > 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? >
