I have a textbox and a grid displaying 10 lines of item.
First, I modified data in grid.
Then while editing the second line of data, I found clicking out of the grid will not set the focus out from the grid.
Why and How can I set the grid out from edit mode when I click out of the grid?
Please advice, Thanks.
private void Form1_MouseClick(object sender, MouseEventArgs e)
{
ultraGrid1.PerformAction(UltraGridAction.ExitEditMode);
}
If the forms have many other controls, is it I had to add this mouse click event to all other controls in order to force ultragrid to trigger the ExitEditMode event?
you can set it on the grid lost focus event to trigger the exiteditmode when other controls got focus, and keep the form mouse click to trigger when no other control get focus
Hi Hady,
I did added in the LostFocus but it is not get trigger as well.
Can you checked why is it?
Attached is my sample application.
Many thanks.
Crystal
use the lost focus event when going to other control (i.e. button, textbox...) (p.s. you have to add the event's method in the constructor or on form load. check the sample)
and the form click event when clicking outside.
I found that it is not works for GroupBox control. Clicking on control in the groupbox will not trigger lost focus event?
See my sample.
Thanks!!!
The grid will automatically write any pending changes to the underlying data source when it loses focus. So you don't really have to do anything in that case.
If you want to force the grid to update in a case where the grid is not losing focus, then you can use the grid.UpdateData() method. You may need to also call grid.PerformAction(ExitEditMode) before the call to UpdateData in order to take the current cell out of edit mode, if there is one.
Thanks Hady!
So, we need to use UltraGrid LostFocus event for those control that has focus properties; else had to trigger the UltraGrid LostFocus event specifically at those control's MouseClick event.
that's because groupbox doesn't get focus.. labels do not get focus 2.
in such cases you should add event mouse click to the control