hI,
I create a controller for detailview in module.win to switch tab and enter keys to focus control on a form. It works fine for all controls (textbox, combobox, checkbox), except datecontrol and lookupedit control. When i press enter in that controls, show the popup, how to fix that?
How to disable open the popup when i press enter key? I want to work like Tab key.
Thanks
We have closed this ticket because another page addresses its subject:
Layout - How to switch between the Tab and Enter keys to focus controls on a Windows FormProblems with DatePropertyEditor and LookupPropertyEditor when using the EnterMoveNextControl option
Answers approved by DevExpress Support
Hello Tzanis,
The behavior of the DatePropertyEditor as well as ways around it are described in the confused about EnterMoveNextControl ticket. As for the LookupPropertyEditor, you will also likely need to handle the control's KeyDown event and process it accordingly, but I would need some additional time to verify. I will update this thread if a different solution is required for this editor.
UPDATE:
The LookupEdit control used by our LookupPropertyEditor listens to the keyboard and shows a popup as a result. So, you will have to create custom LookupEdit and LookupPropertyEditor classes to manage this behavior as you want, I am afraid:
C#protected override void OnEditorKeyPress(KeyPressEventArgs e) {
base.OnEditorKeyPress(e);
if(!Properties.ReadOnly && !e.Handled && e.KeyChar != '\t') {
char charCode = e.KeyChar;
if(Properties.CharacterCasing != CharacterCasing.Normal) {
charCode = Properties.CharacterCasing == CharacterCasing.Lower ? Char.ToLower(e.KeyChar) : Char.ToUpper(e.KeyChar);
}
ShowPopup();
if(!Char.IsControl(charCode) || charCode == '\b') {
string searchString = charCode == '\b' ? "" : charCode.ToString();
PopupForm.Template.SetStartSearchString(searchString);
}
e.Handled = true; //B30072
}
}
protected override void OnEditorKeyDown(KeyEventArgs e) {
base.OnEditorKeyDown(e);
if(e.KeyData == (Keys.Down | Keys.Alt) || e.KeyCode == Keys.Delete) {
if(!Properties.ReadOnly && !e.Handled) {
ShowPopup();
PopupForm.Template.SetStartSearchString("");
e.Handled = true;
}
}
}
Tzanis,
If you are looking for the source code of the built-in editors I mentioned, then it is installed on your machine:
<YourDevExpressInstallationFolder>\Components\Sources\DevExpress.ExpressApp\DevExpress.ExpressApp.Win\Editors\DatePropertyEditor.cs
<YourDevExpressInstallationFolder>\Components\Sources\DevExpress.ExpressApp\DevExpress.ExpressApp.Win\Editors\LookupPropertyEditor.cs
If you are asking for a sample implementing the aforementioned solutions, then I am afraid we do not have a ready one at the moment. I will be more than happy to help you implement these solutions if you experience any concrete difficulties with them, though.
Other Answers
Thank you very much Dennis