I currently have an UltraGrid control, which has multiple bands. When I'm on a band[0] line I want to be able to add keyboard shortcuts (such as ALT+C or ALT+P) to add a new row to one of the child bands. I've figured out the code to add the row to the desired child band, expand to the new row and activate edit mode on it; however I still can't find a satisfactory way to do this from the keyboard.
During my investigations I found the ability to add a GridKeyActionMapping, however the things that are performed seem to be limited to the list of events, so my query is - can I somehow override this to fire a method of my own?
Or, is there a better/different way of doing what I'm trying to achieve?
Many thanks in advance for your help.
Hello Martin,
I am just checking about the progress of this issue. Let me know If you need my further assistance on this issue?
Thank you for using Infragistics Components.
This case fires when you press both the ALT key and the N key. The ALT key is a special key and it can be only interpreted and transmitted when using dual-character combinations. I have chosen the Alt + N combination for your scenario but you can choose whatever combination you want:
case [ special key like Shift,Alt,Ctrl] | [a key]
Please do not hesitate to contact me if you have any further question.
@Mike - Thanks for your response, I had assume that that would be the case.
@Atanas - Thanks also for your reply and example code. It's a while since I've coded in C# so can you just confirm that the following code does what I think it does:
*SNIP* case Keys.Alt | Keys.N: DoWork(ref e); *SNIP*
*SNIP*
case Keys.Alt | Keys.N: DoWork(ref e);
Essentially, this case fires if the ALT key OR the N key are pressed? Rather than the ALT key AND the N key? I've tried multiple different ways of coding this, including using e.Modifiers.Alt and still can't get it to work properly - this is more likely due to the language I'm using (I'm programming in a language called OpenEdge - GUI for .NET) rather than the code itself as logically I would expect the code to work.
Thanks both for your assistance!
In order to add a new row to a specific child band using a keyboard combination you could use the KeyDown event of the UltraGrid. When you press the desired combination this event is fired and according to the combination a method which adds the new row to a specific child band is called. Using a switch statement in the body of the KeyDown event gives you the opportunity to clasp other combinations that perform other methods.
I’ve implemented this suggestion in a simple sample, and you could run and evaluate it, please see attached zip.
Please let me know if you have any further questions.
Hi,
In theory, it might be possible to define your own value and insert it into the KeyActionMappings. But this assumes that the grid is not deliberately validating the values to make sure they are valid. And, quite frankly, it's a lot more trouble than it's worth for no real benefit.
A much simpler way to do this would be to simply handle the KeyDown event of the grid.