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
Hi Milko
Thank you for your quick reply.
disabling the events on the MouseEnterElement works pretty well.
The only issue is that there are some events that are not disabled.
I found that the MouseDown and MouseUp events are not disabled.
However, i was able to get around that, by checking the AllEventsEnabled property in those two events.
This seems to work for me.
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.