Hi,
I used my own UserControl (Editing and Rendering) in UltraContainerControl. This UserControl contains 1 UltraLabel, 1 UltraTextEditor.
I would like do some validation in my UltraTextEditor when press tab, enter, mouse click to prevent user from leaving the cell.
I use BeforeExitEditMode on my UltraTextEditor, but when I click with mouse on other row, new row is selected but the UltraTextEditor is already in edit mode.
How can I used correctly this behaviour with UltraControlContainer and BeforeExitEditMode ?
Thanks a lot.
Thanks for your reply.
I tried your solution to derive my UserControl from Control instead of UserControl. It seems to work better. BeforeExitEditMode will no longer trigger twice.
However, I use BeforeExitEditMode event of my grids to prevent user from leaving cell.
In fact, when e.Cancel = true, user can't leave the cell but my editing control lost focus when press TAB.
Here a sample (WindowsFormsApplication1.zip) that demonstrate my issue. You can enter edit mode in COL2 of ultraGrid1 (A 10). If you try to leave cell with mouse, you can't leave the cell (it's works like a charm).
But if you try to leave cell with TAB key, my editing control lose focus but grid is always in edit mode.I don't know where is my focus.
If you press again TAB key, my editing control recover the focus.
It's possible to stay in my editing control like I use mouse to exit edit mode ?
Thanks a lot...
Hello Booorf,
Could you please if possible try to attach a small sample project, reproducing your scenario for us. It is not easy to guess what is the issue here and an example will be needed in order to find a resolution faster.
Booorf said:When I click on other part of my screen (out of my usercontrol), BeforeExitEditModen raise 2 times.
I'm pretty sure that this is a bug in the DotNet framework and is related to the fact that UserControl derives from ContainerControl. The ContainerControl class has some strange issues when dealing with focus changes.
I recommend avoiding ContainerControl, if you can. For example, you might be able to derive your control from Control instead of UserControl.
Booorf said: In this case, isValid() function return false -> (e.Cancel = true), but despite evaluate e.Cancel = true, it still leaves the cell. It's not normal ? If e.Cancel = true, UltraGrid doesn't ext edit mode ?!
In this case, isValid() function return false -> (e.Cancel = true), but despite evaluate e.Cancel = true, it still leaves the cell.
It's not normal ? If e.Cancel = true, UltraGrid doesn't ext edit mode ?!
I'm not sure I understand what you mean here. This might be a case where the grid is trying to keep the focus on the cell in edit mode and the DotNet Framework simply won't let it. Or it might be that the cell is not exiting edit mode and the grid is just losing focus, anyway.
I'm afraid I really couldn't guess without being able to see the behavior in action and debug it. Can you post a small sample project demonstrating this behavior?
Thanks for your reply. In fact, my UltraGrid are in a UserControl. I catch BeforeExitEditMode event on my grid to do some validation to prevent user leaving cell. When I change (click) on other grid or other cell it's works like a charm because other grid is in my UserControl.
When I click on other part of my screen (out of my usercontrol), BeforeExitEditModen raise 2 times. In each time the cell is validate, therefore e.Cancel = !isValid();
Do you have an idea ?
Thanks a lot
I think this kind of validation will be very complicated and difficult. I'm not sure that this is possible.
What I would do is use the BeforeExitEditMode event of the grid, instead.