DataGrid scroll bar size

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
 
A

Alex Yakhnin [MVP]

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.
 
I

Ian Williamson

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;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top