Current filter:
                                You should refresh the page.
                                  • Hi,

                                    I need to create a custom TextEdit-like control that supports the following features:

                                    1. Use regex edit masks
                                    2. Provide AutoComplete functionality
                                    3. Support use of buttons.

                                    My current approach was to change the behavior of a ComboBox accordingly. This already works for requirement 1 and 3; however, the AutoComplete does not work properly. The suggestion is shown in the popup, but the user can neither select the suggestion with the arrow key nor by clicking on it. The Text/EditValue does not change. I read that there should be a PopUpClosed event I could register and then update the Text accordingly, but it seems this is just available for WPF ComboBoxes?!

                                    Note: my ComboBox does not have/need any Items. The whole control should just allow the user to enter a valid value which is backed by an own datasource for auto completion.

                                    I currently activate the AutoComplete functionality of the ComboBox that way:

                                    this.MaskBox.AutoCompleteSource = AutoCompleteSource.CustomSource; this.MaskBox.AutoCompleteMode = AutoCompleteMode.Suggest; this.MaskBox.AutoCompleteCustomSource = new AutoCompleteStringCollection(); this.MaskBox.AutoCompleteCustomSource.AddRange(autoCompleteSource);

                                    Trying to use other controls as base for my control, I had to face different other problems:
                                    LookUpEdit supports requirement 2 and 3, but not 1
                                    TextEdit supports 1 and 2 but not 3.

                                    Do you have any idea what to use to support all 3 requirements?

                                    Best regards,

                                1 Solution

                                Creation Date Importance Sort by

                                Internally, our editors own a text box that implements the text input functionality. The text box is represented by the TextBoxMaskBox class. It is descendant of a standard TextBox control's . So, the auto complete feature is provided by the standard TextBox.
                                If you have managed with implementation the 1 and 2 features for TextEdit, I suggest you apply your approach for ButtonEdit. It is the closest editor to TextEdit that supports adding buttons. Please test this and let me know your results.

                                Show all comments
                                • JuWu 08.21.2019

                                  Hi Maxim,

                                  unfortunately I face the same behavior with the ButtonEdit as with the ComboBoxEdit.
                                  I have to admit that I tested the implementation with TextEdit not properly before. Here the AutoComplete did not work as expected as well.

                                  For all three types I face the following behavior, when I type one letter that is part of the auto complete source :
                                   - the popup shows but vanishes within less than a second.
                                   - if I continue writing the popup does not appear again
                                   - if I delete one character, the popup is shown again and remains displayed as long as I don't continue typing.
                                   - if I now want to select the suggestion either via arrow down key or directly via clicking at it, the popup is closed, but the text in the editor is not updated with the selected suggestion.


                                • Maxim L (DevExpress Support) 08.21.2019

                                  Hi Jürgen,
                                  Can you send us a sample project demonstrating this behavior? We will research it and try to find a solution for you.

                                • JuWu 08.22.2019

                                  Hi Maxim,

                                  please find attached a sample project demonstrating this behavior. In general the control should work as a spin edit control for numeric values, but it shall also allow the user to enter variable names instead of the value, when starting with either '$' or '%' (see Regex-EditMask). If a variable name is entered the control shall suggest already known variable names from the auto-complete source. Furthermore a button is displayed to enter a default value for this variable.

                                  Steps to reproduce the auto-complete problem:
                                   - enter any character part of the auto complete data source (e.g. %t)
                                          --> Source: MaskBox.AutoCompleteCustomSource.AddRange(new[] {"%test1", "%test2", "$asdf", "$qwerty"});

                                • JuWu 08.22.2019

                                  Sorry, the attachment was not added properly...

                                • Maxim L (DevExpress Support) 08.22.2019

                                  We need additional time to prepare an answer to your inquiry. We appreciate your understanding.

                                • Maxim L (DevExpress Support) 08.23.2019

                                  Hi Jürgen,
                                  Thank you for your project I see the behavior.
                                  Our RegEx mask specified via the MaskType property doesn't use the auto-complete source set for an editor's MaskBox (TextBox). And there is no easy way to make it do this.
                                  As far as I understand your idea, you want to create an editor for editing numbers, but an end-user can also input some text and this text should be parsed to a number. The goal of using a regex mask is to prevent an end-user from inputting some letters. At the same time, you want to use the auto-complete function.
                                  If so, I suggest you implement your task in the following way:
                                  Use the standard auto-complete mechanism provided via TextBox. To prevent a user from inputting unwanted symbols, handle an editor's KeyDown event.To parse your custom text, handle the ParseEditValue event.To use an editor similar to SpinEdit but with supporting the string text, create a descendant of the BaseSpinEdit editor.
                                  I attached a sample demonstrating the main idea in action. I hope you will find it helpful.

                                • JuWu 08.26.2019

                                  Hi Maxim,

                                  thanks for your solution; however, I'll stick with me own implementation as I adapted it already to my needs. I now implemented the regex-edit mask by my own in the KeyDown event as you suggested (see code below). Now my ComboBoxEdit fulfills all 3 above described requirements.

                                  Looking at the code below that now checks the user input based on a regex and allows for using autocomplete sources (like your regex edit mask functionality would be supposed to do) I don't really understand why your controls won't work with autocomplete sources at all?
                                  Having to identify the bug in your controls and finding a (in the end relatively simple) solution for it, cost me quite some time...
                                  My suggestion would be to implement this functionality correctly in a future version of your controls or at least document this shortcoming better to save other people facing the same issue a lot of time.

                                  Here's my solution to overcome the shortcoming:

                                  private void this_KeyDown(object sender, KeyEventArgs e)

                                  { var input = Utilities.KeyCodeToUnicode(e.KeyCode); if (string.IsNullOrEmpty(input) || input.Length > 1 || char.IsControl(input.ToCharArray()[0])) return; var newText = this.Text; if (this.SelectionLength > 0) newText = this.Text.Remove(this.SelectionStart, this.SelectionLength); newText += input; if (!_regex.IsMatch(newText)) { e.SuppressKeyPress = true; e.Handled = true; } }
                                • Maxim L (DevExpress Support) 08.27.2019

                                  I'm happy to hear that you have found a solution.
                                  As I mentioned earlier, the auto-complete feature with AutoCompleteCustomSource is provided by the standard TextBox. However, the editor's mask functionality is our own feature. At present, we don't adapt our masks for the standard TextBox's auto-completion feature. I agree with you that it would very helpful in some scenarios. So, we will consider the possibility of implementing it in newer versions.
                                  Thank you for your feedback.