When the CustomerControlBox drops down it gets focus. I understand this is by design. However focus is not restored to the control having focus before the drop down.
My application consists of one or more grids managed by an UltraMdiTabManager, to the right there are FormattedTextControls docked at the right edge.
If I describe the scenario causing problem:
1. Click/type in one of the TextControl, that becomes the active control
2. Click/type in the grid, that receives focus but the text control is still shown as the active control from my main form
3. When the color box drops down it gets focus
4. When the ColorChanged event fires, focus has been set to the TextControl which was active but did not have focus, but not to the grid that previously had focus, meaning my color command is sent to the wrong control
Regardless of what I do in terms of ActiveControl or Select it seems I can not get the main form to see the grid with focus as the active control. I assume that focus is restored to the active control?
I currently have a work around by identifying the control with focus in BeforeToolDropDown event handler recursively using ContainsFocus instead of ActiveControl and then restoring focus before applying the color command. This works OK.
However I assume there is a better solution, any suggestions?
Hello Mats,
I followed the steps you suggested and was unable to reproduce the behavior you're describing. I have created small sample project with ToolbarsManager containing one toolbar with ColorPicker tool. I have added UltraTextEditor docked to the right. Then I have added UltraTabbedMdiManager. At run time I have created several MDI child forms each one containing an UltraGrid. I have clicked on the UltraTextEditor and then on one of the MDI child form’s grid and it get activated. Then I have clicked over the ColorPicker, have chosen some color and the focus returned back to grid’s cell.
I have attached the sample project I used to test this. Please test this project on your PC; whether or not it works correctly may help indicate the nature of this issue.
If the project does not work correctly, this indicates either an issue possibly specific to your environment, or a difference in the DLL versions we are using. My test was performed using version 15.2.20152.2023 in Infragistics for Windows Forms 2015 Volume 2. So could you please let me know the exact version of Infragistics components which you are using?
If the project does show the product feature working correctly, this indicates a possible issue in the code of your application. It will help if you can provide a small, isolated sample application that demonstrates the behavior you are seeing.
Or, if this sample project is not an accurate demonstration of what you're trying to do, please feel free to modify it and send it back.
Please let me know if I can provide any further assistance.
Hi Milko,
Your solution work as expected.
I am running 15.2.20152.1000 so I will update and check for any difference, currently on the road so it will take a couple of days.
However my control hierarchy is a bit more complicated, sorry for simplifying. My grid is contained within a splitter which in turn is contained within a splitter in the grid form.
I have updated your solution in the same way (it is attached). In that case the Enter event never fires and the solution never reaches a break point in ultraGrid1_Enter on my system, could you check? This looks similar to the behavior I am seeing for my own solution.
I have tried hacking a an event handler for change of ActiveControl as suggested in this link: http://www.codeproject.com/Tips/552519/Detect-Change-In-ActiveControl. With that code in place in my own solution I can never see that a click in the grid leads to a change of the active control although the opposite is true, that a click in the text box can lead to a change.
If I log the complete control hierarchy with active control and focus properties I can see that after a click in the grid
- grid has focus
- next level splitter has grid as the active control
- top level splitter has bottom splitter as the active control
- grid form has null as active control
- an the main form has the text control as the active control
Any ideas?
/Mats
Have installed the service release "2023". So far I can see no difference in behavior.
Thank you for your feedback.
I have tested your modified project and here is what I have found:
You did not actually handled InitializeLayout, Enter and Leave events of the grid. Please check the attached updated sample where I have subscribed your handlers for these events. Now both Enter and Leave events fires every time you activate the grid;
If I click on the grid cell the grid becomes the active control. If I click then on color picker the grid is still the active control. It does not deactivate. This is expected behavior.
In grid’s Enter event handler you have tried to get the active control. Please check the updated project where I have implement this logic.
Please check my sample and let me know if you are able to reproduce this behavior with it.
Looking forward to your reply.