We have some code that uses the .net Windows.Forms.TreeView. When an item in the view is selected then code does
treeView.BeginUpdate();
// ... some stuff ...
SendMessage(treeView.Handle, WM_HSCROLL, SB_LEFT, 0);
treeView.EndUpdate();
This is so that the tree view display doesn't scroll right (which is the default behaviour - to show as much of the selected item label as possible I assume but at the expense of hiding some of the tree structure). Unfortunately when the tree view contains 30,000 items and this code is called during a right-click and results in the context menu takes a couple of seconds to appear (enough to be disconcerting).
If you remove the Begin/EndUpdate, then the context menu appears instantly, but you get an annoying twitch as you see the view move right and then back the left edge. The suggestion of getting rid of the "push it back to the left edge" scroll is encountering some resistance.
I've tried filtering out SB_RIGHT on the tree view but that doesn't seem to actually be used to when the control moves to show the label.
So is there a way of keeping the tree view in at it's current horizontal scroll position when the item is selected that doesn't involve Begin/EndUpdate and the corresponding lag or the twitch?