Compact Framework – Increasing ScrollBar Width

The Datagrid in the Compact Framework has fixed 13 pixel wide/tall scrollbars but no way to resize them. Creating a control that inherits from Datagrid, overriding the size of the scrollbars would be one way to go, but it can be achieved without the need to do this by using reflection.

FieldInfo fieldInfo = dgBinDetail.GetType().GetField("m_sbVert", BindingFlags.NonPublic | BindingFlags.GetField | BindingFlags.Instance);

((VScrollBar)fieldInfo.GetValue(dgBinDetail)).Width = 30; 

Remember to add the System.Reflection namespace to your list of using statements at the top of your class.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s