We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Excel Like Navigation and Entry + Possible KeyDown Event Defect

Hi,

I have attached a demo project that simulates Excel like navigation and selection. Other developers may find this useful.

e.g.
-Holding ctrl plus arrow key down skips to the next change from empty to filled cell (or vice versa).
-Shift Ctrl plus arrow key selects all cells between active and the next change from empty to filled cell (or vice versa).

The behaviour is slightly different to Excel in that it skips to both cells on either side of the empty/filled cell interfaces. But the result is the same in that it makes it much quicker to navigate around the spreadsheet and select tables of data.

I also attempted to simulate the Excel behaviour that allows multiple entry of the same value into all selected cells.
When entering a value in a cell; rather than simply pressing enter to enter the value, holding the ctrl key down while pressing enter should fill all of the selected cells with the value entered. So selecting range A1:B2 and typing '5' in cell A1 and holding ctrl + [enter] should fill cells A1:B2 with the number '5'.
The code to do this starts on line 110 in SyncExcelLikeNavigation, which attempts to trap the combination of the ctrl key hold and [enter]:

else if (m_grid.CurrentCell.IsEditing && e.Control && !e.Alt && (e.KeyCode == Keys.Enter) && !e.Shift)

However, it seems that the key code does not show enter when the ctrl key is held down. To confirm this, view the output window with the results of the statement on line 79:

Debug.WriteLine(Enum.GetName(typeof(Keys), e.KeyCode));

Is this a defect?
When will it be resolved?
Is there a work around?

Many thanks,
Steve

EnterKeyDemo.zip

2 Replies

ST steve_randomno September 24, 2007 10:37 AM UTC

If I submit these questions in Direct-Trac will I get a faster response?

How do I get a log on for Direct-Trac?

Many thanks,
Steve


SM Stephen Main September 26, 2007 06:27 AM UTC

Hi,

Once I managed to get a logon, I got a quick response from DirectTrac:

In KeyDown event, 'Enter' key is recognized only when you select the set of cells, 'Control' and 'Enter' keys are pressed, but not when the current cell is edited. For this scenario, as a best approach you can use CurrentCellKeyDown of grid control that will recognizes the keys that are pressed when the current cell is edited.

The following code snippet is used for invoking CurrentCellKeyDown event.

[C#]
m_grid.CurrentCellKeyDown+=new KeyEventHandler(m_grid_CurrentCellKeyDown);

Please refer the modified sample and let us know if you have any other issues.

I have attached a working version of the demo for any body else who is interested.

Many thanks,
Steve


EnterKeyDemo_Fixed.zip

Loader.
Live Chat Icon For mobile
Up arrow icon