radCheckedDropDownList textbox content

6 posts, 0 answers
  1. Phillip
    Phillip avatar
    3 posts
    Member since:
    Jul 2016

    Posted 20 Jul Link to this post

    I am using the radCheckedDropDownList control with MultiLine set to True and AutoCompleteMode set to Suggest.  When a user types text into the edit portion of the control and autocomplete fails to find a match the text remains in the edit portion upon leaving the control.  If the user selects an item in the list the unmatched text string is removed when the drop down list is closed.  Is there a way to either restrict the user entered text to the content of the checked drop down list or cause the edit portion of the control to refresh (remove the partial text) when a match is not found and the user leaves the control?

    Thanks.

  2. Dess
    Admin
    Dess avatar
    1609 posts

    Posted 21 Jul Link to this post

    Hello Phillip,

    Thank you for writing. 

    You can prevent the user from entering invalid text in the editable part of the RadCheckedDropDownList by canceling the CheckedDropDownListElement.AutoCompleteEditableAreaElement.AutoCompleteTextBox.TextChanging event. Thus, you can check whether there are suggestions for the newly entered text.

    I hope this information helps. Should you have further questions I would be glad to help.

    Regards,
    Dess
    Telerik by Progress
    Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms.For more information check out this blog post and share your thoughts.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Phillip
    Phillip avatar
    3 posts
    Member since:
    Jul 2016

    Posted 21 Jul in reply to Dess Link to this post

    Dess,

    I have subscribed to the recommended event and created the following method stub.  While this prevents the user from entering a character that does not match the first character of an item in the dropdown list, it prevents the user from selecting an item in the dropdown list by clicking on the checkbox.  Another anomaly is that after typing in a character and then pressing Tab or Enter the selected item is not tokenized in the text box portion of the control (see attachment).  Can you recommend coding changes to the event logic to resolve these issues?  Also, I have the DropDownStyle property set to DropDownList which should prevent the user from typing in the text box portion of the control.  Am I misunderstanding this property or is there an issue with the implementation of this property in the radCheckedDropDownList control?

            private void TextBoxItem_TextChanging(object sender, TextChangingEventArgs e)
            {
                if (radCheckedDropDownList1.FindString(e.NewValue) == -1)
                {
                    e.Cancel = true;
                }
            }

     

    Phillip

  5. Dess
    Admin
    Dess avatar
    1609 posts

    Posted 22 Jul Link to this post

    Hello Phillip,

    Thank you for writing back. 

    You can handle the CheckedDropDownListElement.AutoCompleteEditableAreaElement.AutoCompleteTextBox.AutoCompleteDropDown.MouseDown event and detect whether a visual item is clicked. Afterwards, you shouldn't cancel the TextChanging event:
    bool shouldCancel = true;
     
    private void AutoCompleteDropDown_MouseDown(object sender, MouseEventArgs e)
    {
        RadListVisualItem el = this.radCheckedDropDownList1.CheckedDropDownListElement.AutoCompleteEditableAreaElement.AutoCompleteTextBox.AutoCompleteDropDown.ElementTree.GetElementAtPoint(e.Location) as RadListVisualItem;
        if (el != null)
        {
            shouldCancel = false;
        }
    }

    I hope this information helps. If you have any additional questions, please let me know.

    Regards,
    Dess
    Telerik by Progress
    Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms.For more information check out this blog post and share your thoughts.
  6. Phillip
    Phillip avatar
    3 posts
    Member since:
    Jul 2016

    Posted 25 Jul in reply to Dess Link to this post

    Dess,

    In the attached image, you will see that upon leaving the control the user entered text is not cleared from the text box control. Is there a method that can be called to clean up the text box control so that only the selected item tokens (if any) are displayed?

    Phillip

  7. Dess
    Admin
    Dess avatar
    1609 posts

    Posted 26 Jul Link to this post

    Hello Phillip,

    Thank you for writing back. 

    There isn't such a method that clears all the text that is not part of any token. However, you can handle the RadCheckedDropDownList.LostFocus event and iterate the CheckedItems collection and update the Text to contain only tokens:
    private void radCheckedDropDownList1_LostFocus(object sender, EventArgs e)
    {
        string delimiter = this.radCheckedDropDownList1.CheckedDropDownListElement.AutoCompleteEditableAreaElement.AutoCompleteTextBox.Delimiter;
        StringBuilder sb = new StringBuilder();
        foreach (RadListDataItem item in this.radCheckedDropDownList1.CheckedItems)
        {
            sb.Append(item.Text + delimiter);
        }
        this.radCheckedDropDownList1.Text = sb.ToString();
    }

    I hope this information helps. If you have any additional questions, please let me know.

    Regards,
    Dess
    Telerik by Progress
    Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms.For more information check out this blog post and share your thoughts.
Back to Top
UI for WinForms is Visual Studio 2017 Ready