Remove button from textbox

2 posts, 0 answers
  1. Terry
    Terry avatar
    39 posts
    Member since:
    Sep 2007

    Posted 20 Aug 2012 Link to this post

    Helo,

    Following on from a piece of code I found in the forums which shows how to add a button to a text box. I can't seem to figure out how to remove it! - Can anybody help?

    Thanks
    Public Sub AddButton()
     
            Dim buttonElement As New RadButtonElement("...")
            AddHandler buttonElement.Click, AddressOf buttonElement_Click
     
            Dim textBoxItem As RadTextBoxItem = Me.RadTextBox1.TextBoxElement.TextBoxItem
            textBoxItem.Alignment = ContentAlignment.MiddleLeft
            Me.RadTextBox1.TextBoxElement.Children.Remove(textBoxItem)
     
             
     
            Dim dockLayoutPanel As New DockLayoutPanel()
     
            dockLayoutPanel.SetDock(textBoxItem, Telerik.WinControls.Layouts.Dock.Left)
            dockLayoutPanel.SetDock(buttonElement, Telerik.WinControls.Layouts.Dock.Right)
     
     
            dockLayoutPanel.Children.Add(buttonElement)
            dockLayoutPanel.Children.Add(textBoxItem)
            Me.RadTextBox1.TextBoxElement.Children.Add(dockLayoutPanel)
     
        End Sub
  2. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 23 Aug 2012 Link to this post

    Hello Terry,

    Thank you for writing.

    Here are a couple of methods demonstrating how to completely remove the button, how to hide it and how to show it, considering that you added it with the method mentioned:
         Sub RemoveButton()
           Me.RadTextBox1.TextBoxElement.Children(2).Children.RemoveAt(0)
       End Sub
     
       Sub HideButton()
           Me.RadTextBox1.TextBoxElement.Children(2).Children(0).Visibility = Telerik.WinControls.ElementVisibility.Collapsed
       End Sub
     
       Sub ShowHiddenButton()
           Me.RadTextBox1.TextBoxElement.Children(2).Children(0).Visibility = Telerik.WinControls.ElementVisibility.Visible
       End Sub

    I hope that you find this information useful.
     
    Regards,
    Stefan
    the Telerik team
    RadControls for WinForms Q2'12 release is now live! Check out what's new or download a free trial >>
  3. UI for WinForms is Visual Studio 2017 Ready
Back to Top