Disable scrollbars
Hi,
I'm new to the dapfor grid and just wanted to know if it's possible to disable the scrollbars.
Thanks,
Michel
-
Hi,
Which scrollbars do you want to disable? Vertical or horizontal one? Do you mean to disable or to hide them?
Regards,
0 -
I want to hide both scrollbars
0 -
Hi,
You can hide the horizontal scrollbar by stretching header columns :
grid.Headers[0].StretchMode = ColumnStretchMode.All;
What is about vertical scrollbar – you can’t do it in the current version, but we'll add this feature into the next version of the grid.
Best Regards,
Dapfor
0 -
Thanks! I was able to solve this for now using the following code (in case anyone else is interested)
public class NoScrollBarGrid : Dapfor.Net.Ui.Grid
{
protected override void WndProc(ref Message m)
{
switch (m.Msg)
{
case 0x83: // WM_NCCALCSIZE
int style = (int)GetWindowLong(this.Handle, GWL_STYLE);
if ((style & WS_VSCROLL) == WS_VSCROLL)
SetWindowLong(this.Handle, GWL_STYLE, style & ~WS_VSCROLL);
if ((style & WS_HSCROLL) == WS_HSCROLL)
SetWindowLong(this.Handle, GWL_STYLE, style & ~WS_HSCROLL);
base.WndProc(ref m);
break;
default:
base.WndProc(ref m);
break;
}
}
const int GWL_STYLE = -16;
const int WS_VSCROLL = 0x00200000;
const int WS_HSCROLL = 0x00100000;public static int GetWindowLong(IntPtr hWnd, int nIndex)
{
if (IntPtr.Size == 4)
return (int)GetWindowLong32(hWnd, nIndex);
else
return (int)(long)GetWindowLongPtr64(hWnd, nIndex);
}public static int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong)
{
if (IntPtr.Size == 4)
return (int)SetWindowLongPtr32(hWnd, nIndex, dwNewLong);
else
return (int)(long)SetWindowLongPtr64(hWnd, nIndex, dwNewLong);
}[DllImport("user32.dll", EntryPoint = "GetWindowLong", CharSet = CharSet.Auto)]
public static extern IntPtr GetWindowLong32(IntPtr hWnd, int nIndex);[DllImport("user32.dll", EntryPoint = "GetWindowLongPtr", CharSet = CharSet.Auto)]
public static extern IntPtr GetWindowLongPtr64(IntPtr hWnd, int nIndex);[DllImport("user32.dll", EntryPoint = "SetWindowLong", CharSet = CharSet.Auto)]
public static extern IntPtr SetWindowLongPtr32(IntPtr hWnd, int nIndex, int dwNewLong);[DllImport("user32.dll", EntryPoint = "SetWindowLongPtr", CharSet = CharSet.Auto)]
public static extern IntPtr SetWindowLongPtr64(IntPtr hWnd, int nIndex, int dwNewLong);}
0
Please sign in to leave a comment.
Comments
4 comments