protected override CreateParams CreateParams
{
get
{
CreateParams cp = base.CreateParams;
cp.ExStyle ^= 0x00200000L; //WS_VSCROLL
return cp;
}
}
I've tested this for WS_HSCROLL, but not WS_VSCROLL, so if I'm wrong feel free to flame me for my lazyness.
Have a nice day,
Robert W. Grubbs
First you should not call CreateParams.ExStyle but CreateParams.Style property because WS_VSCROLL is not an extended style. And using ^(XOR) is not the best approach to remove that style (if it isn't set initially then this operation will asign it).
Removing the L(which stands for "long") from the value will solve your problem:
CreateParams cp = base.CreateParams;
cp.Style &= ~0x00200000; //WS_VSCROLL
return cp;
That should do it.
Cheers,
Gogou
To override CreateParams property you need to inherit from ListBox because CreateParams is protected - visible only for inheritors:
public class MyListBox : ListBox
{
public MyListBox()
{
}
protected override CreateParams CreateParams
{
get
{
CreateParams cp = base.CreateParams;
cp.Style &= ~0x00200000; //WS_VSCROLL
//cp.ExStyle ^= 0x00200000;
return cp;
}
}
}
Then just construct an object of MyListBox and you will not have vertical scrollbar.
Cheers,
Gogou