View Full Version : DotNet Treeview unwanted automatic horizontal scrolling
Jon-Huhn 07-22-2009, 11:27 AM I'm using a DotNet treeview control, and I'm having issues whenever a node is added that is longer than the width of the treeview... it automatically scrolls the treeview horizontally just enough to push the image state icons (or checkboxes, depending) off the left side of the treeview.
Is there any way to turn this off? I can't disable scrolling because obviously the user needs to be able to scroll to get to contents that may be off the screen.
|
|
Jon-Huhn
07-22-2009, 01:22 PM
Upon further investigation, it looks like when I set the .topNode property, that's when this happens. So in effect, that doesn't just set the vertical scroll position, but the horizontal position as well, which isn't what I need. I need to be able to set the vertical position without the horizontal position being effected.
Any ideas?
LoneRobot
07-22-2009, 01:35 PM
hi jon,
cant be sure if this is useful without trying it but the way i'd approach this is by finding out if the treenode's string text is longer than the client rectangle width of the node itself. if so, you could abbreviate /shorten the topnode string.
Either that or shorten the topnode text anyway and store the info you need in the tag property, or a custom event arg in an inherited control.
this might help -
http://www.thescarms.com/dotnet/MeasureString.aspx
MarcoBrunetta
07-22-2009, 03:19 PM
One thing I'd try is using the ensureVisible() method on the selected node ( treeView.selectednode.ensurevisible() ). Ensure visible will surely take care of the vertical scrolling, not sure about the horizontal.
Another thing to try would be to disable the redrawing of the treeview temporarily with beginUpdate() and endUpdate(). Not sure if that will help at all... but it's a good practice anyway.
denisT
07-23-2009, 01:52 AM
One thing I'd try is using the ensureVisible() method on the selected node ( treeView.selectednode.ensurevisible() ). Ensure visible will surely take care of the vertical scrolling, not sure about the horizontal.
Another thing to try would be to disable the redrawing of the treeview temporarily with beginUpdate() and endUpdate(). Not sure if that will help at all... but it's a good practice anyway.
Marco is absolutely right. Before the adding a new node to the list call tv.beginUpdate(). And call tv.endUpdate() after the adding.
denisT
07-23-2009, 02:05 AM
Marco is absolutely right. Before the adding a new node to the list call tv.beginUpdate(). And call tv.endUpdate() after the adding.
oops... i was wrong ... it doesn't work. sorry
denisT
07-23-2009, 02:58 AM
well ... here is a solution:
tv.beginupdate()
tv.nodes.item[?].nodes.add <long named node>
windows.SendMessage tv.handle 0x114 6 0 -- hscroll left
tv.endupdate()
/*
-- WM_HSCROLL = 0x114
-- SB_LEFT = 6
-- SB_RIGHT = 7
windows.SendMessage tv.handle 0x114 6 0 -- hscroll left
windows.SendMessage tv.handle 0x114 7 0 -- hscroll right
*/
Jon-Huhn
07-24-2009, 07:56 PM
Thanks, everyone for your help.
Denis, your suggestion did the trick, thanks a lot!
CGTalk Moderation
07-24-2009, 07:56 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.