Formatting Items
Formatting RadCheckedDropDownList is easy and can be separated in two parts:
Formatting the editable area
In order to customize the editable area, you must subscribe to the TextBlockFormatting event and modify the properties of the TokenizedTextBlockElement:
Subscribe to TextBlockFormatting
this.radCheckedDropDownList1.TextBlockFormatting += radCheckedDropDownList1_TextBlockFormatting;
AddHandler Me.RadCheckedDropDownList1.TextBlockFormatting, AddressOf radCheckedDropDownList1_TextBlockFormatting
Modify properties
void radCheckedDropDownList1_TextBlockFormatting(object sender, TextBlockFormattingEventArgs e)
{
TokenizedTextBlockElement token = e.TextBlock as TokenizedTextBlockElement;
if (token != null)
{
token.ForeColor = Color.DarkBlue;
token.DrawFill = false;
token.BorderColor = Color.DarkRed;
token.BorderWidth = 1.3f;
token.DrawBorder = true;
token.BorderGradientStyle = GradientStyles.Solid;
}
}
Private Sub radCheckedDropDownList1_TextBlockFormatting(sender As Object, e As TextBlockFormattingEventArgs)
Dim token As TokenizedTextBlockElement = TryCast(e.TextBlock, TokenizedTextBlockElement)
If token IsNot Nothing Then
token.ForeColor = Color.DarkBlue
token.DrawFill = False
token.BorderColor = Color.DarkRed
token.BorderWidth = 1.3F
token.DrawBorder = True
token.BorderGradientStyle = GradientStyles.Solid
End If
End Sub
Formatting the drop down items
Customizing the drop down items is similar. Subscribe to the VisualListItemFormatting event:
Subscribe to VisualListItemFormatting
this.radCheckedDropDownList1.VisualListItemFormatting += radCheckedDropDownList1_VisualListItemFormatting;
AddHandler Me.RadCheckedDropDownList1.VisualListItemFormatting, AddressOf radCheckedDropDownList1_VisualListItemFormatting
Modify properties
void radCheckedDropDownList1_VisualListItemFormatting(object sender, VisualItemFormattingEventArgs args)
{
bool itemChecked = ((RadCheckedListDataItem)args.VisualItem.Data).Checked;
if (itemChecked)
{
args.VisualItem.ForeColor = Color.Green;
}
else
{
args.VisualItem.ForeColor = Color.Red;
}
}
Private Sub radCheckedDropDownList1_VisualListItemFormatting(sender As Object, args As VisualItemFormattingEventArgs)
Dim itemChecked As Boolean = DirectCast(args.VisualItem.Data, RadCheckedListDataItem).Checked
If itemChecked Then
args.VisualItem.ForeColor = Color.Green
Else
args.VisualItem.ForeColor = Color.Red
End If
End Sub