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 4272
James,
You must add the message filter to the application class in the form load
event
//add message filter.
Application.AddMessageFilter(this); //this= the form where IMessageFilter
is implemented
Shak
(Houston)
"James" <ja*****************@yahoo.com.au> wrote in message
news:e6**************************@posting.google.c om... 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
Yes I have already done that,(I did not include those parts of code).
The problem is when I want to scroll the data grid on that form. Other
functions work fine.
foe example,
if(m.Msg == WM_KEYDOWN && keyCode == Keys.F1)
{
dv.Sort = "by some column";
return true;
}
these work fine, it only does not work for scroll.
I just wanted to find out if there was anything wrong with
int position = 500;
SendMessage(dataGrid1.Handle, WM_VSCROLL, SB_THUMBPOSITION + 0x10000 *
position,0);
Thanks This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Randy |
last post by:
Hello,
I have two questions...
I have a datagrid. I'm capturing the cell via HitTestInfo.
The first question is fairly simple. I'm using an example of how to capture
the row/column I found on the...
|
by: Gidi |
last post by:
Hello
i'm writing a C# Window appliction and i'm using DataGrid as a table
i want the user to enter data in each column and by pressing the enter key to move to the next column
how can i write it...
|
by: Gidi |
last post by:
hello i'm writing an appliction in C# and i have 2 questions:
1. i have a dataGrid which contains data from my DataBase, and when the dataGrid loads the scroll is at the first line and i want it...
|
by: pei_world |
last post by:
I want to implement a key hit with enter to dropdown a combobox that is in
the datagrid. in this case I need to override its original behaviours. I
found some codes from the web. Does anyone know...
|
by: headbig003 |
last post by:
Hello
I am using dataset to populate datagrid.
I use button outside of datagrid to insert new row and update datagrid.
After updated or inserted new information to datagrid, user has to...
|
by: A.M |
last post by:
Hi,
I want to refresh my DataGrid data on every postback.
I have following code in Page_Load event, but after first page load, the
DataGrid never gets refresh.
Here is the code i have in...
|
by: Suzanne |
last post by:
I'd like to know how can I put up a confirmation question when the
user tries to delete a row in the datagrid by clicking on the row
header and pressing the Delete key?
I have found this code on...
|
by: Agnes |
last post by:
I set my datagrid's datasource programmically . However , as the form load,
I found that every column width is the same,
Question 1) How can i adjust it programmically ???
Question 2) I need to do...
|
by: Lars Netzel |
last post by:
My question is about how to get more info on what's happening while
debugging in this scenario...
My cursor is in the last cell of a datagrid row... I press TAB and the
CerrentCellChanged is...
|
by: amiga500 |
last post by:
Hello,
I have one basic simple question. When I have multiple records in the
datagrid as follows:
Code Product 1 Product 2 Product 3
11111 A B C...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
| |