Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
205
Select all text in ComboBoxTool
posted

Is there any way how to select all text in ComboBoxTool by a single click? I am looking for something like SelectAll() for ComboBox.

Thanks, Maksim.

Parents
  • 6158
    Offline posted

    The ComboxBoxTool does not have a SelectAll() method, but you can achieve the same functionality by using the SelectStart and SelectionLength properties. By setting the SelectionStart to 0 and the SelectionLength to the length of the tool's Text, you can achieve the same behavior as SelectAll().

    Additionally, you could simply set the SelectedText property to the value of the Text property.

    There are two requirements to text selection. First, the tool must be in edit-mode. This can be accomplished by setting the IsInEditMode property to true. Second, the tool must support text selection which is handled by the DropDownStyle property. The default DropDownStyle is DropDownList which does not support text editing/selection. Change the DropDownStyle property to DropDown to allow both text editing and selection. Here is a quick code snippet that will select all the text in ComboxTool1 when a button on the form is clicked:

    private void button1_Click(object sender, EventArgs e)

    {

    ComboBoxTool tool = this.ultraToolbarsManager1.Toolbars[0].Tools["ComboBoxTool1"] as ComboBoxTool;

    if (tool.DropDownStyle == Infragistics.Win.DropDownStyle.DropDown)

    {

    tool.IsInEditMode = true;

    tool.SelectedText = tool.Text;

    // Or...

    //tool.SelectionStart = 0;

    //tool.SelectionLength = tool.Text.Length;

    }

    }

    Let me know if you have any questions.

    Chris

Reply Children