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
570
Disable events for empty rows.
posted

Hi

We are using the UltraGrid in many areas of our product and recently set the ShowEmptyRows property to true for the grid.

There is a lot of event handling for the grid such as Click, ClickCell, ClickCellButton, DoubleClick, DoubleClickCell, etc.

I am seeing that the events are fired for the empty rows the same as the non-empty rows.

This is causing a lot of problems as there is no data in the empty rows.

It would be a major undertaking to add handling for empty rows in the grid event handlers in our product.

Is there a property that can be set or some other way to disable the events from firing on the empty rows?

Thanks

Harlan

Parents
No Data
Reply
  • 21795
    Verified Answer
    Offline posted

    Hello Harlan,

    You can disable all the grid events by setting AllEventsEnabled of the grid EventManager to false. However, there are no separate events for the empty grid rows. What you can do is handle MouseEnterElement and MouseLeaveElement events of the grid. In this events check if the mouse has entered / has left the empty rows area UIElement (EmptyRowsAreaUIElement). If so disable all the grid events on mouse enter and enable back all the events on mouse leave. Do not forget to leave MouseLeaveElement always on. You can use code like this:

    private void UltraGrid1_MouseLeaveElement(object sender, UIElementEventArgs e)
    {
        if(e.Element is EmptyRowsAreaUIElement)
        {
            //  If the mouse leaves the empty rows area enable all the grid events
            this.ultraGrid1.EventManager.AllEventsEnabled = true;
        }
    }
     
    private void UltraGrid1_MouseEnterElement(object sender, UIElementEventArgs e)
    {
        if(e.Element is EmptyRowsAreaUIElement)
        {
            //  If the mouse enters empty rows area disable all grid events. Enable only
            //  MouseLeaveElement event in order to be able to restore grid events state
            //  when mouse leave the empty rows area
            //
            this.ultraGrid1.EventManager.AllEventsEnabled = false;
            this.ultraGrid1.EventManager.SetEnabled(GridEventIds.MouseLeaveElement, true);
        }
    }

    Attached is a small sample project showing this approach. Please check my sample and let me know if any additional questions on this matter arise.

    UltraGridEmptyRowsEvents.zip
Children