RadTextBox With DropDownButton

2 posts, 0 answers
  1. Fabricio
    Fabricio avatar
    1 posts
    Member since:
    Nov 2014

    Posted 12 Apr 2016 Link to this post

    01.internal class RadTextBoxWithDropDownButton : RadTextBox
    02.{
    03.    public RadDropDownButtonElement DropDownButtonElement { get; private set; }
    04. 
    05.    public RadTextBoxWithDropDownButton()
    06.    {
    07.        DropDownButtonElement = new RadDropDownButtonElement
    08.        {
    09.            Padding = new Padding(2, 0, 2, -2),
    10.            Margin = new Padding(0, 0, 0, 0),
    11.            Text = " "
    12.        };
    13. 
    14.        var stackLayoutElement = new StackLayoutElement
    15.        {
    16.            Orientation = Orientation.Horizontal,
    17.            Margin = new Padding(1, 0, 1, 0)
    18.        };
    19. 
    20.        stackLayoutElement.Children.Add(DropDownButtonElement);
    21. 
    22.        var textBoxItem = TextBoxElement.TextBoxItem;
    23.        TextBoxElement.Children.Remove(textBoxItem);
    24. 
    25.        var dockLayoutPanel = new DockLayoutPanel();
    26.        dockLayoutPanel.Children.Add(stackLayoutElement);
    27.        dockLayoutPanel.Children.Add(textBoxItem);
    28.        DockLayoutPanel.SetDock(textBoxItem, Telerik.WinControls.Layouts.Dock.Left);
    29.        DockLayoutPanel.SetDock(stackLayoutElement, Telerik.WinControls.Layouts.Dock.Right);
    30. 
    31.        TextBoxElement.Children.Add(dockLayoutPanel);
    32. 
    33.        TextBoxElement.Padding = new Padding(1, 1, 1, 1);
    34.        Margin = new Padding(0, 1, 0, 0);
    35.    }
    36.}
  2. Dess
    Admin
    Dess avatar
    1678 posts

    Posted 12 Apr 2016 Link to this post

    Hello Fabricio,

    Thank you for writing.

    The provided sample code snippet is greatly appreciated. The following help article demonstrates a sample approach for inserting a RadElement in RadTextBox: http://docs.telerik.com/devtools/winforms/editors/textbox/adding-buttons-to-radtextbox

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

     Regards,
    Dess
    Telerik
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Back to Top