This is a migrated thread and some comments may be shown as answers.

help: select all text on CommandBarDropDownList1

4 Answers 51 Views
CommandBar
This is a migrated thread and some comments may be shown as answers.
ricric
Top achievements
Rank 1
ricric asked on 09 Jul 2011, 03:42 AM
how can i select all text when i click the text on CommandBarDropDownList1 ?

thanks for your help..

4 Answers, 1 is accepted

Sort by
0
Ivan Todorov
Telerik team
answered on 13 Jul 2011, 05:30 PM
Hello Ricric,

You can achieve this by subscribing to the events of the hosted text box. I am posting you an example that demonstrates this:
public partial class CommandBarSample : Form
{
    private bool isEntering;
 
    public CommandBarSample()
    {
        InitializeComponent();
 
        this.commandBarDropDownList1.DropDownListElement.TextBox.TextBoxItem.HostedControl.Enter += new EventHandler(CommandBarSample_Enter);
        this.commandBarDropDownList1.DropDownListElement.TextBox.TextBoxItem.HostedControl.MouseDown += new MouseEventHandler(HostedControl_MouseDown);
    }
 
    void HostedControl_MouseDown(object sender, MouseEventArgs e)
    {
        if (this.isEntering)
        {
            this.isEntering = false;
            (this.commandBarDropDownList1.DropDownListElement.TextBox.TextBoxItem.HostedControl as TextBox).SelectAll();
        }
    }
 
    void CommandBarSample_Enter(object sender, EventArgs e)
    {
        this.isEntering = true;
        (this.commandBarDropDownList1.DropDownListElement.TextBox.TextBoxItem.HostedControl as TextBox).SelectAll();
    }
 
}

I hope this is useful. Feel free to ask if you have any additional questions.

Best wishes,
Ivan Todorov
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

0
ricric
Top achievements
Rank 1
answered on 17 Jul 2011, 03:47 AM
could you translate the code in vb.net please?
thanks.
0
Accepted
Ivan Todorov
Telerik team
answered on 21 Jul 2011, 08:21 AM
Hi Ricric,

Here is the same code, translated into VB:
Public Partial Class CommandBarSample
    Inherits Form
    Private isEntering As Boolean
 
    Public Sub New()
        InitializeComponent()
 
        AddHandler Me.commandBarDropDownList1.DropDownListElement.TextBox.TextBoxItem.HostedControl.Enter, AddressOf CommandBarSample_Enter
        AddHandler Me.commandBarDropDownList1.DropDownListElement.TextBox.TextBoxItem.HostedControl.MouseDown, AddressOf HostedControl_MouseDown
    End Sub
 
    Private Sub HostedControl_MouseDown(sender As Object, e As MouseEventArgs)
        If Me.isEntering Then
            Me.isEntering = False
            TryCast(Me.commandBarDropDownList1.DropDownListElement.TextBox.TextBoxItem.HostedControl, TextBox).SelectAll()
        End If
    End Sub
 
    Private Sub CommandBarSample_Enter(sender As Object, e As EventArgs)
        Me.isEntering = True
        TryCast(Me.commandBarDropDownList1.DropDownListElement.TextBox.TextBoxItem.HostedControl, TextBox).SelectAll()
    End Sub
 
End Class

In case you need to translate code snippets in the future, you can use our free Code Converter tool.

Hope this helps.

Kind regards,
Ivan Todorov
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

0
ricric
Top achievements
Rank 1
answered on 21 Jul 2011, 11:16 AM
ok, thank you.
Tags
CommandBar
Asked by
ricric
Top achievements
Rank 1
Answers by
Ivan Todorov
Telerik team
ricric
Top achievements
Rank 1
Share this question
or