In my application I always want hscrollbar.LargeChange
to equal panel.Width
. Currently I set hscrollbar.LargeChange
to panel.Width
in resizing events, painting events, et cetera. I do not know much about binding so I'm wondering if it is possible to do this.
Sorry if this is a simple question but when I tried googling binding and c# I got a lot of complicated information about other platforms.
Actually, there is a way to bind the LargeChange property of the HScrollBar to the Width property of the panel, but I think I've just discovered a bug in .NET 4 with regards to this as it works if I target .NET 3.5.
Basically, you need to manually create a Binding object and assign it to the HScrollBar's DataBindings collection, like so:
hScrollBar1.DataBindings.Add(new Binding("LargeChange", panel1, "Size.Width", true, DataSourceUpdateMode.OnPropertyChanged));
Again, this doesn't work in .NET 4, but it does in .NET 3.5. I'll probably submit a bug report.
Cheers
Yes, the way you are doing it, in the panel.Resize event is the only way to do it in windows forms.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.