Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
240
keyboard action to click button
posted

I have an ultra grid used for data entry.  I'd like to allow the users to not have to use a mouse.

I added a column with style editor button.  When the user enters into this field, I'd like them to be

able to optionally simulate a mouse click on the button without having to use a mouse.  Is there a

way to set focus to the button or is there a hot key combination that will simulate the button click?

Thanks,

Rick

  • 12480
    Suggested Answer
    Offline posted

    Hi Rick,

    Although it's possible to simulate a mouse click in Windows, I don't recommend handling this that way.

    Instead, you could handle the grid's KeyPress event and look for the desired shortcut key combination. From there, you could call the same logic that occurs in the button click handler. The code might look something like this:

    private void ultraGrid1_KeyPress(object sender, KeyPressEventArgs e)
    {
       switch (e.KeyChar)
       {
           case Keys.E:
                if (ModifierKeys.HasFlag(Keys.Control))
               {
                   OpenStyleEditor();
               }
           default:
               break;
       }
    }

    In this example, the OpenStyleEditor method would contain the logic that runs when a user clicked the style editor button. Please let me know if this works.