Hallo,
I am using Visual Studio.net 2003. When i press ctrl + A in the datagrid all rows get selected, which is the default behaviour. Which event gets fired when i press ctrl+A In keydown event handler either "ctrl" gets captured or "A". Can anybody explain me how the rows get selected Or which method gets called by this event
thanks
swingme

Datagrid selection
sar3000
The datagrid control has a method called ProcessGridKey which gets to look at any key presses before you - the select all code is in here. You can find this method using Refletor. The good news it is protected, so you can override it and handle the ctrl+a (or any other keys) yourself.
Hope thats useful.
Simon.
rungsan
Ok, you need to create a descendant datagrid, and override the ProcessGridKey method. Something like this in c# (apologies for any typo's I'm writing this straight into the forum).
public class MyNewDataGrid : DataGrid
{
protected override bool ProcessGridKey(KeyEventArgs ke)
{
if (ke.KeyCode == Keys.A && ke.Control)
{
//Do whatever you want to do here instead of select all...
}
else
return base.ProcessGridKey(ke); //let the base class deal with other keys...
}
}
That should give you an idea.
Simon.
vitjan
thanks for ur response.could u please give me a small example
swingme
MELO
it captures only one key. i mean either ctrl or A
thanks
swingme
SaurabhKhurana
Sorry.