collages
asked on
Treeview - Hiding Horizontal Scrollbar
I have a treeview which nodes are added and deleted every so often and the horizontal position of scroll bar changes.
Is there a way i can fix the horizontal scrollbar to one position
- or -
Get rid of it entirely?
Either one of these solutions would be acceptable.
Is there a way i can fix the horizontal scrollbar to one position
- or -
Get rid of it entirely?
Either one of these solutions would be acceptable.
do you use beginupdate() endupdate method before and after your add cycle?
ASKER
Yes i do.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
here is a tree which works. you will just have to implement the flag i mentioned:
public class CustomTreeView : TreeView
{
private const int WM_NCCALCSIZE = 0x0083;
private const int SB_HORZ = 0;
private const int SB_VERT = 1;
private const int SB_CTL = 2;
private const int SB_BOTH = 3;
[DllImport("user32.dll")]
private static extern int ShowScrollBar(IntPtr hWnd, int wBar, int bShow);
public CustomTreeView() : base()
{
}
protected override void WndProc(ref Message m)
{
switch(m.Msg)
{
case WM_NCCALCSIZE:
ShowScrollBar(base.Handle, SB_BOTH, 0);
break;
}
base.WndProc(ref m);
}
}
public class CustomTreeView : TreeView
{
private const int WM_NCCALCSIZE = 0x0083;
private const int SB_HORZ = 0;
private const int SB_VERT = 1;
private const int SB_CTL = 2;
private const int SB_BOTH = 3;
[DllImport("user32.dll")]
private static extern int ShowScrollBar(IntPtr hWnd, int wBar, int bShow);
public CustomTreeView() : base()
{
}
protected override void WndProc(ref Message m)
{
switch(m.Msg)
{
case WM_NCCALCSIZE:
ShowScrollBar(base.Handle,
break;
}
base.WndProc(ref m);
}
}
ASKER
Perfect.