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.
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.
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();
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 ?!
Do you have an idea ?
Thanks a lot
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 ?!
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.
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,
I made the following changes and if I got your requirements right I believe that it is working fine:
private void answerUltraTextEditor_BeforeExitEditMode(object sender, Infragistics.Win.BeforeExitEditModeEventArgs e) { //if (e.IsForcingExit) return; if (tabbingOut) { tabbingOut = false; e.Cancel = true; } tabbingOut = false; }
bool tabbingOut = false; private void answerUltraTextEditor_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Tab) { tabbingOut = true; } else tabbingOut = false;
Please feel free to let me know if I misunderstood you or if you have any other questions.
I am checking about the progress of this issue. Please let me know If you need any further assistance on this.
We are going to need a specific example without all the extra code and components in order to look into this and find the issue that is causing this behavior. Could you please share a much simpler application, so that we will able to resolve this for you.
I created the following case for you: 'CAS-90766-VMX15M' and will update you through it.
Thanks for your reply. Your following changes it's working fine.
I made some changes in my sample to demonstrate a new issue with BeforeExitEditMode. I put my two grids in an UltraPanel and in a UserControl.
I added some DockingPane on the left on the screen and a UltraTExtEditor on the right of the screen.
If you entering in ultraGrid1 COL2 (A 10). You click on the first docking left pane. BeforeExitEditMode of ultraGrid1 is raised with e.cancel = true. But you can enter in the UltraTextEditor to change value text. But ultraGrid1 is already in edit mode with cursor hidden.
It's seems to be a bug ?