Reputation: 45
I need to change the scroll bar width of a c# winform FlowLayoutPanel
but no luck in finding how.
Anyone knows?
Upvotes: 1
Views: 3574
Reputation: 718
simply setting the Vertical scroll as so :
flowLayoutPanel1.Controls.OfType<VScrollBar>().First().Width = 20; //or any int value as you want
and for Horizontal :
flowLayoutPanel1.Controls.OfType<HScrollBar>().First().Height = 15;
but before this snippet you may need to be sure that there is a scroll bar showing on the control or not..
i didn't work with a flowLayoutpanel before..so i don't know why you use this control in winforms..
but to give you a logic / idea of controlling the scrollbar showing on the control or not..
i use this logic with datagridview..
1-) I, simply calculate the "Displayed total rows height" and "Total Displayed columns width"
2-) if total rows height is bigger than current datagridview height it means there will be a scrollbar..Also the same for the other scrollbar (columns width is bigger than dgv width)
But if you are sure that there is a scrollbar shows on your control then above code lines will set the width or height as your need..
Upvotes: 1
Reputation: 2405
I don't think you can do that in the way you want. Maybe you can build your own, please take a look here http://www.codeproject.com/KB/miscctrl/customscrollbar.aspx
There are already a some Q/A regarding this matter here.
Upvotes: 0