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

Add Button to DropDown Arrow Button's Right

2 Answers 85 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
DoomerDGR8
Top achievements
Rank 2
Iron
Iron
Veteran
DoomerDGR8 asked on 14 Feb 2011, 05:59 PM
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 Answers, 1 is accepted

Sort by
0
Richard Slade
Top achievements
Rank 2
answered on 15 Feb 2011, 10:39 AM
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
0
Peter
Telerik team
answered on 17 Feb 2011, 09:27 AM
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.
Tags
DropDownList
Asked by
DoomerDGR8
Top achievements
Rank 2
Iron
Iron
Veteran
Answers by
Richard Slade
Top achievements
Rank 2
Peter
Telerik team
Share this question
or