Add Button to DropDown Arrow Button's Right

3 posts, 0 answers
  1. DoomerDGR8
    DoomerDGR8 avatar
    133 posts
    Member since:
    Aug 2010

    Posted 14 Feb 2011 Link to this post

    Hello!

    Here is a peice of code that allows us to add a Button in a TextEdit:

    private void SetupSpecialControls() {
        RadButtonElement buttonElement = new RadButtonElement("...");
        buttonElement.Click += buttonElement_Click;
     
        RadTextBoxItem textBoxItem = Text_Update_BI_BatchNo.TextBoxElement.TextBoxItem;
        textBoxItem.Alignment = ContentAlignment.MiddleLeft;
     
        Text_Update_BI_BatchNo.TextBoxElement.Children.Remove(textBoxItem);
     
        DockLayoutPanel.SetDock(textBoxItem, Telerik.WinControls.Layouts.Dock.Left);
        DockLayoutPanel.SetDock(buttonElement, Telerik.WinControls.Layouts.Dock.Right);
     
        DockLayoutPanel dockLayoutPanel = new DockLayoutPanel();
     
        dockLayoutPanel.Children.Add(buttonElement);
        dockLayoutPanel.Children.Add(textBoxItem);
     
        Text_Update_BI_BatchNo.TextBoxElement.Children.Add(dockLayoutPanel);
     
      }

    Now, I need to add a button next to the drop-down-arrow-button in a DropDownList control
  2. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 15 Feb 2011 Link to this post

    Hi Hassan,

    I think you might have sizing issues trying to do this in all your controls. In my view it would be easier and safer to create a custom control that combines a RadDropDownList and a RadButton which you can then drag onto your forms from the toolbox like any other.

    Hope that helps
    Richard
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Peter
    Admin
    Peter avatar
    1148 posts

    Posted 17 Feb 2011 Link to this post

    Hi Hassan,

    RadDropDownList does not allow you to add a button right after the Arrow Button and I would like to suggest that you use Richard's solution regarding a user control.

    However, if you modify your code to work with RadDropDownList's TextBox, you will be able to add a button before the Arrow button.

    RadButtonElement buttonElement = new RadButtonElement("...");
    RadTextBoxItem textBoxItem = radDropDownList1.DropDownListElement.EditableElement.TextBox.TextBoxItem;
    textBoxItem.Alignment = ContentAlignment.MiddleLeft;
    radDropDownList1.DropDownListElement.EditableElement.TextBox.Children.Remove(textBoxItem);
    DockLayoutPanel.SetDock(textBoxItem, Telerik.WinControls.Layouts.Dock.Left);
    DockLayoutPanel.SetDock(buttonElement, Telerik.WinControls.Layouts.Dock.Right);
    DockLayoutPanel dockLayoutPanel = new DockLayoutPanel();
    dockLayoutPanel.Children.Add(buttonElement);
    dockLayoutPanel.Children.Add(textBoxItem);
    radDropDownList1.DropDownListElement.EditableElement.TextBox.Children.Add(dockLayoutPanel);

    I hope this helps.

    All the best,
    Peter
    the Telerik team
    Q3’10 SP1 of RadControls for WinForms is available for download; also available is the Q1'11 Roadmap for Telerik Windows Forms controls.
Back to Top