DataGrid scroll bar size

  • Thread starter Thread starter Gianco
  • Start date Start date
G

Gianco

Hello

I enlarged the size of scroll bars to semplify the use of the touch
screen for my application increasing the value of the following
registry voices:

cyHScr : Horizontal Scrollbars Height in pixels
cxHScr : Horizontal Scrollbars Width in pixels
cyVScr : Vertical Scrollbars Height in pixels
cxVScr : Vertical Scrollbars Width in pixels

located in \HKLM\SYSTEM\GWE

Everything works fine (combo and list boxes) but the DataGrid objects
still show a thin vertical scroll bar (but with an higher arrow
bitmap) and a low horizontal scroll bar (but with a wider arrow
bitmap), probably I'm making something wrong...

Can anyone help me?

Many thanks
Gianco
 
probably I'm making something wrong...

I don't think it's you. It looks like the scrollbar sizes
are hardcoded inside of the DataGrid.
 
You can use the following reflective code to adjust the
size of the scrollbars. Just replace "myWidth"
and "myHeight" with the integer of your choosing.

Note that this code is pulled from the constructor of a
custom DataGrid. If you wish to call it from outside the
DataGrid, replace references to "this" with your grid's
object name.

using System.Reflection;

.....

FieldInfo fi = this.GetType().GetField("m_sbVert",
BindingFlags.NonPublic|BindingFlags.GetField|BindingFlags.
Instance);
((VScrollBar)fi.GetValue(this)).Width = myWidth;
fi = this.GetType().GetField("m_sbHorz",
BindingFlags.NonPublic|BindingFlags.GetField|BindingFlags.
Instance);
((HScrollBar)fi.GetValue(this)).Height = myHeight;
 
Back
Top