Yes, this is quite straight forward to add a TextBoxElement to the RadSplitButton. I have altered my original sample as below.
using
System.Collections.Generic;
using
System.Windows.Forms;
using
Telerik.WinControls;
using
Telerik.WinControls.UI;
using
Telerik.WinControls.RadControlSpy;
namespace
RadControlsWinFormsApp1
{
public
partial
class
Form1 : Form
{
private
List<Person> people =
new
List<Person>();
private
RadPanel m_Panel;
private
RadGridView m_Grid;
private
RadTextBoxElement m_TextBox;
private
System.Drawing.Size m_Size =
new
System.Drawing.Size(300, 200);
public
Form1()
{
InitializeComponent();
RadControlSpyForm form =
new
RadControlSpyForm();
form.Show();
m_TextBox =
new
RadTextBoxElement();
m_TextBox.TextBoxItem.ReadOnly =
true
;
people.Add(
new
Person(
"Richard"
,
false
));
people.Add(
new
Person(
"Peter"
,
true
));
people.Add(
new
Person(
"Chris"
,
false
));
people.Add(
new
Person(
"Stew"
,
true
));
people.Add(
new
Person(
"Bob"
,
false
));
people.Add(
new
Person(
"Leisl"
,
false
));
m_Grid =
new
RadGridView();
m_Grid.AllowAddNewRow =
false
;
m_Grid.EnableFiltering =
true
;
m_Grid.ShowRowHeaderColumn =
false
;
m_Grid.EnableGrouping =
false
;
m_Grid.ShowFilteringRow =
true
;
m_Grid.AutoSizeRows =
true
;
m_Grid.DataBindingComplete +=
new
GridViewBindingCompleteEventHandler(m_Grid_DataBindingComplete);
m_Grid.DataSource = people;
m_Panel =
new
RadPanel();
m_Panel.Controls.Add(m_Grid);
m_Grid.Dock = DockStyle.Fill;
RadMenuItem item =
new
RadMenuItem();
item.MaxSize = m_Size;
this
.radSplitButton1.Items.Add(item);
this
.radSplitButton1.DropDownButtonElement.DropDownMenu.PopupOpened +=
new
RadPopupOpenedEventHandler(DropDownMenu_PopupOpened);
this
.radSplitButton1.DropDownButtonElement.DropDownMenu.PopupClosing +=
new
RadPopupClosingEventHandler(DropDownMenu_PopupClosing);
// force show to data bind
this
.radSplitButton1.DropDownButtonElement.ShowDropDown();
this
.radSplitButton1.DropDownButtonElement.HideDropDown();
}
private
void
Form1_Load(
object
sender, System.EventArgs e)
{
// add a textbox element to the SplitButton
m_TextBox.AutoSize =
false
;
m_TextBox.Size =
new
System.Drawing.Size(
this
.radSplitButton1.DropDownButtonElement.ActionButton.Size.Width,
this
.radSplitButton1.DropDownButtonElement.ActionButton.Size.Height + 1);
this
.radSplitButton1.DropDownButtonElement.ActionButton.Children.Add(m_TextBox);
}
void
DropDownMenu_PopupClosing(
object
sender, RadPopupClosingEventArgs args)
{
m_Grid.EndEdit();
SetText();
}
void
m_Grid_DataBindingComplete(
object
sender, GridViewBindingCompleteEventArgs e)
{
m_Grid.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
m_Grid.Columns[
"Name"
].ReadOnly =
true
;
m_Grid.Columns[
"HasBeard"
].ReadOnly =
false
;
m_Grid.Columns[
"Name"
].BestFit();
m_Grid.Columns[
"HasBeard"
].BestFit();
SetText();
}
void
DropDownMenu_PopupOpened(
object
sender, System.EventArgs args)
{
this
.radSplitButton1.DropDownButtonElement.DropDownMenu.PopupElement.MaxSize = m_Size;
this
.radSplitButton1.Items.Clear();
m_Panel.Size = m_Size;
RadMenuItem item =
new
RadMenuItem();
item.AutoSize =
false
;
item.BackColor = System.Drawing.Color.Transparent;
item.Size = m_Panel.Size;
item.Alignment = System.Drawing.ContentAlignment.MiddleCenter;
item.Children.Add(
new
RadHostItem(m_Panel));
this
.radSplitButton1.Items.Add(item);
}
private
void
SetText()
{
string
people =
""
;
foreach
(GridViewRowInfo row
in
m_Grid.ChildRows)
{
if
(row
is
GridViewDataRowInfo)
{
if
(((
bool
)row.Cells[
"HasBeard"
].Value) ==
true
)
{
people = people + row.Cells[
"Name"
].Value.ToString() +
";"
;
}
}
}
if
(people.Length > 0)
{
people = people.Remove(people.Length-1, 1);
this
.m_TextBox.Text = people +
" have beards"
;
}
else
{
this
.m_TextBox.Text =
"nobody has a beard"
;
}
}
}
public
class
Person
{
public
Person(
string
name,
bool
hasBeard)
{
this
.Name = name;
this
.HasBeard = hasBeard; }
public
string
Name
{
get
;
set
; }
public
bool
HasBeard
{
get
;
set
; }
}
}