Search code examples
delphidelphi-xe2tcxgrid

Call Onclick event for cxGrid Navigator buttons


How does one Call the Onclick event for cxGrid Navigator buttons? I can't seem to find it.

Screenshot below...

enter image description here

Thanks,


Solution

  • In the following example View is the TcxGridDBTableView owning the Navigator:

    The Navigator Buttons are exposed via a property on View called NavigatorButtons. NavigatorButtons is of type TcxNavigatorControlButtons

    On TcxNavigatorControlButtons you'll find all you buttons:

      TcxNavigatorControlButtons = class(TcxCustomNavigatorButtons)
      ...
      published
        property ConfirmDelete;
        property CustomButtons;
        property Images;
    
        property First;
        property PriorPage;
        property Prior;
        property Next;
        property NextPage;
        property Last;
        property Insert;
        property Append;
        property Delete;
        property Edit;
        property Post;
        property Cancel;
        property Refresh;
        property SaveBookmark;
        property GotoBookmark;
        property Filter;
      end;
    

    So if you want to click on the "Next" button you could write

      View.NavigatorButtons.Next.Click;
    

    IF and only IF the button is enabled then the OnClick event will fire.

    There are 16 buttons, each one defined byt it's own index:

    const
      NavigatorButtonCount = 16;
    
      NBDI_FIRST        = 0;
      NBDI_PRIORPAGE    = 1;
      NBDI_PRIOR        = 2;
      NBDI_NEXT         = 3;
      NBDI_NEXTPAGE     = 4;
      NBDI_LAST         = 5;
      NBDI_INSERT       = 6;
      NBDI_APPEND       = 7;
      NBDI_DELETE       = 8;
      NBDI_EDIT         = 9;
      NBDI_POST         = 10;
      NBDI_CANCEL       = 11;
      NBDI_REFRESH      = 12;
      NBDI_SAVEBOOKMARK = 13;
      NBDI_GOTOBOOKMARK = 14;
      NBDI_FILTER       = 15;
    

    If you prefer you can ude this index to click a certain button:

     View.NavigatorButtons.ClickButton(NBDI_EDIT);
    

    Hope this answers your question.