Hello Daniel,
Thank you for writing.
You can introduce a public property returning the
RadCheckBoxElement. Afterwards, you can iterate the AutoCompleteBoxViewElement.
Children collection and find the checked
TokenizedTextBlockElements:
public
Form1()
{
InitializeComponent();
this
.radAutoCompleteBox1.CreateTextBlock += radAutoCompleteBox1_CreateTextBlock;
this
.radAutoCompleteBox1.AutoCompleteDataSource =
this
.customersBindingSource;
this
.radAutoCompleteBox1.AutoCompleteDisplayMember =
"ContactName"
;
this
.radAutoCompleteBox1.AutoCompleteValueMember =
"CustomerID"
;
}
private
void
radAutoCompleteBox1_CreateTextBlock(
object
sender, Telerik.WinControls.UI.CreateTextBlockEventArgs e)
{
if
(e.TextBlock
is
TokenizedTextBlockElement)
{
e.TextBlock =
new
MyTokenizedTextBlockElement();
}
}
public
class
MyTokenizedTextBlockElement : TokenizedTextBlockElement
{
private
RadCheckBoxElement checkBox;
public
RadCheckBoxElement CheckBox
{
get
{
return
this
.checkBox;
}
}
protected
override
Type ThemeEffectiveType
{
get
{
return
typeof
(TokenizedTextBlockElement);
}
}
protected
override
void
CreateChildElements()
{
base
.CreateChildElements();
int
index =
this
.Children.IndexOf(
this
.RemoveButton);
this
.checkBox =
new
RadCheckBoxElement();
this
.checkBox.StretchVertically =
true
;
this
.checkBox.StretchHorizontally =
false
;
this
.checkBox.Checked =
true
;
this
.Children.Insert(index,
this
.checkBox);
}
}
private
void
radButton1_Click(
object
sender, EventArgs e)
{
foreach
(MyTokenizedTextBlockElement item
in
this
.radAutoCompleteBox1.TextBoxElement.ViewElement.Children)
{
if
(item.CheckBox.Checked)
{
Console.WriteLine(item.Item.Text);
}
}
}
I hope this information helps. Should you have further questions, I would be glad to help.
Regards,
Dess
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.