J
James
1. up/down arrow keys to move up/down one recored at a time
2. Page Up/Down keys to move up/down one page at a time
3. CTRL+End and CTRL+Home keys to move to end and beginning(last
record and first record) of the datagrid respectively
code for page down:
public class Myform : System.Windows.Forms.Form, IMessageFilter
{
const int WM_KEYDOWN = 0x100;
const int WM_KEYUP = 0x101;
[DllImport("User32.dll")]
private static extern int SendMessage(IntPtr hWnd, int msg , int
wParam, int lParam);
public const int SBS_HORZ = 0;
public const int SBS_VERT = 1;
public const int SBS_CTL = 2;
public const int SBS_BOTH = 3;
public const int WM_VSCROLL = 0x115;
public const int WM_HSCROLL = 0x114;
public const int SB_LINEUP = 0;
public const int SB_LINEDOWN = 1;
public const int SB_PAGEUP = 2;
public const int SB_PAGEDOWN = 3;
public const int SB_THUMBPOSITION = 4;
public const int SB_THUMBTRACK = 5;
public const int SB_TOP = 6;
public const int SB_BOTTOM = 7;
public const int SB_ENDSCROLL = 8;
public bool PreFilterMessage(ref Message m)
{
Keys keyCode = (Keys)(int)m.WParam & Keys.KeyCode;
if(m.Msg == WM_KEYDOWN && keyCode == Keys.PageDown)
{
int position = 500;
SendMessage(dataGrid1.Handle, WM_VSCROLL, SB_THUMBPOSITION +
0x10000 * position,0);
return true;
}
}
}
Nothing is happening, does any one have any sample code to handle the
above mentioned events(1,2,3).
Thanks
2. Page Up/Down keys to move up/down one page at a time
3. CTRL+End and CTRL+Home keys to move to end and beginning(last
record and first record) of the datagrid respectively
code for page down:
public class Myform : System.Windows.Forms.Form, IMessageFilter
{
const int WM_KEYDOWN = 0x100;
const int WM_KEYUP = 0x101;
[DllImport("User32.dll")]
private static extern int SendMessage(IntPtr hWnd, int msg , int
wParam, int lParam);
public const int SBS_HORZ = 0;
public const int SBS_VERT = 1;
public const int SBS_CTL = 2;
public const int SBS_BOTH = 3;
public const int WM_VSCROLL = 0x115;
public const int WM_HSCROLL = 0x114;
public const int SB_LINEUP = 0;
public const int SB_LINEDOWN = 1;
public const int SB_PAGEUP = 2;
public const int SB_PAGEDOWN = 3;
public const int SB_THUMBPOSITION = 4;
public const int SB_THUMBTRACK = 5;
public const int SB_TOP = 6;
public const int SB_BOTTOM = 7;
public const int SB_ENDSCROLL = 8;
public bool PreFilterMessage(ref Message m)
{
Keys keyCode = (Keys)(int)m.WParam & Keys.KeyCode;
if(m.Msg == WM_KEYDOWN && keyCode == Keys.PageDown)
{
int position = 500;
SendMessage(dataGrid1.Handle, WM_VSCROLL, SB_THUMBPOSITION +
0x10000 * position,0);
return true;
}
}
}
Nothing is happening, does any one have any sample code to handle the
above mentioned events(1,2,3).
Thanks