UltraGrids' KeyPress/KeyDown not working - Forum - Community Groups - Progress Community

UltraGrids' KeyPress/KeyDown not working

 Forum

UltraGrids' KeyPress/KeyDown not working

This question is answered

L.S.

I have an ultragrid which, by a user action, is bound to a particular bindingsource. Everything works fine. However, I have to click on a row (CellClickEvent = RowSelect) in order to make the KeyPress/KeyDown event work, and that's not desirable.

I have tried the following, without success:

- UltraGrid:Select().
- UltraGrid:Focus().
- UltraGrid:DataBind().
- UltraGrid:PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction:ActivateCell).
- UltraGrid:ActiveRow = StatusBarGrid:Rows:Item[0]. 
  UltraGrid:Selected:Rows:Add(UltraGrid:ActiveRow).

Hope you can help, TIA.
Will

Verified Answer
  • Are you sure that your grid has focus? If you have to click on a row first and then your keydown event works then it probably indicates that your grid does not have focus by the time you expect it to have focus. What you can try and do is to set the Form's KeyPreview property to TRUE and then you can trap any KeyDown or KeyUp event anywhere on the form in the Form's events instead. You might then even be able to see what control has focus.

    Regards,
     Mark Davies
    ProSoft – Software and Business Solutions
    Cell: +27 (0)73 287 1254
    Fax: +27 (0)86 0126530750
    www.prosoftit.co.za
    markd@prosoftit.co.za

    View my Microsoft Certification Transcripts

    On 14/08/2015 10:31 AM, WJCPvanBeek wrote:
    Thread created by WJCPvanBeek

    L.S.

    I have an ultragrid which, by a user action, is bound to a particular bindingsource. Everything works fine. However, I have to click on a row (CellClickEvent = RowSelect) in order to make the KeyPress/KeyDown event work, and that's not desirable.

    I have tried the following, without success:

    - UltraGrid:Select().
    - UltraGrid:Focus().
    - UltraGrid:DataBind().
    - UltraGrid:PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction:ActivateCell).
    - UltraGrid:ActiveRow = StatusBarGrid:Rows:Item[0]. 
      UltraGrid:Selected:Rows:Add(UltraGrid:ActiveRow).

    Hope you can help, TIA.
    Will

    Stop receiving emails on this subject.

    Flag this post as spam/abuse.


    Regards,

    Mark Davies

All Replies
  • Are you sure that your grid has focus? If you have to click on a row first and then your keydown event works then it probably indicates that your grid does not have focus by the time you expect it to have focus. What you can try and do is to set the Form's KeyPreview property to TRUE and then you can trap any KeyDown or KeyUp event anywhere on the form in the Form's events instead. You might then even be able to see what control has focus.

    Regards,
     Mark Davies
    ProSoft – Software and Business Solutions
    Cell: +27 (0)73 287 1254
    Fax: +27 (0)86 0126530750
    www.prosoftit.co.za
    markd@prosoftit.co.za

    View my Microsoft Certification Transcripts

    On 14/08/2015 10:31 AM, WJCPvanBeek wrote:
    Thread created by WJCPvanBeek

    L.S.

    I have an ultragrid which, by a user action, is bound to a particular bindingsource. Everything works fine. However, I have to click on a row (CellClickEvent = RowSelect) in order to make the KeyPress/KeyDown event work, and that's not desirable.

    I have tried the following, without success:

    - UltraGrid:Select().
    - UltraGrid:Focus().
    - UltraGrid:DataBind().
    - UltraGrid:PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction:ActivateCell).
    - UltraGrid:ActiveRow = StatusBarGrid:Rows:Item[0]. 
      UltraGrid:Selected:Rows:Add(UltraGrid:ActiveRow).

    Hope you can help, TIA.
    Will

    Stop receiving emails on this subject.

    Flag this post as spam/abuse.


    Regards,

    Mark Davies

  • The UltraGrid has focus because it responds to the LostFocus event.

    When I use a 'simple' version: putting an ultragrid, containing some dummy data, on a form, the KeyPress event fires as expected.

    In my more 'complex' version the ultragrid is put on  a System.Windows.Forms.UserControl. When this usercontrol is instantiated, its constructor receives the reference to a form. Next the ultragrid is removed from the controlscollection of the usercontrol and added to the controlscollection of the the form.

    But that's the only difference with the 'simple' version.

    Any clues ?

    TIA Will

  • Hi Mark,

    I have implemented your solution and it works.

    Thx a lot for your support.

    regards,

    Will