Is there some way, how to make scrollbar wider in winforms for .net compact framework? I want to be application finger-friendly, but the scrollbars are very narrow for peopl
Here is my take on this:
mydatagrid.Contorls[0]
would be the horizontal scrollbar.
This can be done byname maybe I'll post a more elaborate solution later.Once you've reached the correct control, it is simply a matter of updating the Height property of the scrollbar, right?...wrong!! Remember the scrollbar is an element within the datagrid/listbox...therefore it's original location (painting position) is set at a point which would enable the element to be seen at the height value it was initialized at... so your code will have to deal with the repositioning of the scrollbar location within the original rectangle.
myDataGrid.Controls[0].Height = myDataGrid.Controls[0].Height + 60;
myDataGrid.Controls[0].Location = new Point(myDataGrid.Controls[0].Location.X, myDataGrid.Controls[0].Location.Y - 60);
Finally things to consider: When you play around with the scrollbar size, you need to remember other parts of the element depend on the scrollbar, for instance if the scrollbar ends up hiding some rows on the grid, they won't be reachable...
I haven´t checked that, because I have no device but rumor has it that you can change the Size per Regstry Settings:
[HKEY_LOCAL_MACHINE\SYSTEM\GWE]
cyHScr=13 - Default height of horizontal scrollbar
cxVScr=13 - Default width of vertical scrollbar
Kind Regards
Thomas
You can use reflection. Inspired by this link, my code would look something like this. (It may be a bit too careful, but I am not so sure how generic this would be with reflection. E.g. the VScrollBar is not found for a TextBox on this form.)
using System.Reflection;
//...
public static void SetVerticalScrollbarWidth(Control c, int w)
{
try
{
var lGridVerticScrollBar = GetNonPublicFieldByReflection<VScrollBar>(c, "m_sbVert");
lGridVerticScrollBar.Width = w;
}
catch
{
// fail soft
}
}
public DataGridForm()
{
SetVerticalScrollbarWidth(dataGrid, 30);
}
public static T GetNonPublicFieldByReflection<T>(object o, string name)
{
if (o != null)
{
Type lType = o.GetType();
if (lType != null)
{
var lFieldInfo = lType.GetField(name, BindingFlags.NonPublic | BindingFlags.GetField | BindingFlags.Instance);
if (lFieldInfo != null)
{
var lFieldValue = lFieldInfo.GetValue(o);
if (lFieldValue != null)
{
return (T)lFieldValue;
}
}
}
}
throw new InvalidCastException("Error in GetNonPublicFieldByReflection for " + o.ToString() );
}
VB version:
'Increase size of the Vertical scrollbar of your DataGrid'
For Each vBar As VScrollBar In yourDG.Controls.OfType(Of VScrollBar)()
vBar.Width = 25
Next
'Increase size of the Horizontal scrollbar of your DataGrid'
For Each hBar As HScrollBar In yourDG.Controls.OfType(Of HScrollBar)()
hBar.Height = 25
Next
All the thx goes to Yahoo Serious.