I want to disable scrolling ( not hide the scroll bar but disallow scrolling altogether) when the user selects certain items in my listbox if the user moves to a differnet item ( the criterai are not important ) then I want to re-enable scrolling How can I do this in .NET 2.0
A:
Override CreateParams property of ListBox class.
public class My : ListBox
{
protected override CreateParams CreateParams
{
get
{
CreateParams cp = base.CreateParams;
cp.Style &= ~0x00200000; // VScroll
return cp;
}
}
}
Add following code to test,
private void Form1_Load(object sender, EventArgs e)
{
My c = new My();
for (int i = 1; i <= 100; i++){
c.Items.Add(i.ToString());
}
this.Controls.Add(c);
}
adatapost
2009-08-31 05:57:11
this worls on XP but not on Vistaany idea why
Rahul
2009-09-13 19:22:45