Hello Miki,
You can set the BorderPrimitive Width property to specify the border width, when BorStyle is SingleBorder.
In regards to the MouseEnter event, as I explained in my post from Jan 2, RadDropDownList internally hosts TextBox control (when in DropDown mode), hence the observed behavior with the enter and leave events. This is what required usage of timer and you should introduce your enter color in the MouseEnter event handler, and your reset color in the timer_Tick event handler:
protected
override
void
OnLoad(EventArgs e)
{
base
.OnLoad(e);
InitializeComponent();
AddDropDownList();
new
TelerikMetroBlueTheme();
radDropDownList1.ThemeName =
"TelerikMetroBlue"
;
new
VisualStudio2012LightTheme();
// radDropDownList1.ThemeName = "VisualStudio2012Light";
BorderPrimitive ddlBorder = (BorderPrimitive)radDropDownList1.DropDownListElement.Children[0];
ddlBorder.ForeColor = Color.FromArgb(27, 161, 226);
ddlBorder.BoxStyle = BorderBoxStyle.SingleBorder;
ddlBorder.Width = 5;
radDropDownList1.DropDownListElement.ArrowButton.Border.Visibility = ElementVisibility.Collapsed;
radDropDownList1.DropDownListElement.ArrowButton.Fill.Visibility = ElementVisibility.Collapsed;
radDropDownList1.DropDownListElement.EditableElement.DrawBorder =
false
;
radDropDownList1.MouseEnter += radDropDownList1_MouseEnter;
timer1 =
new
System.Windows.Forms.Timer();
timer1.Interval = 200;
timer1.Tick +=
new
EventHandler(timer1_Tick);
timer1.Enabled =
true
;
}
System.Windows.Forms.Timer timer1;
void
radDropDownList1_MouseEnter(
object
sender, EventArgs e)
{
((FillPrimitive)radDropDownList1.DropDownListElement.Children[1]).BackColor = Color.FromArgb(27, 161, 226);
radDropDownList1.DropDownListElement.EditableElement.BackColor = Color.FromArgb(27, 161, 226);
radDropDownList1.DropDownListElement.EditableElement.TextBox.BackColor = Color.FromArgb(27, 161, 226);
radDropDownList1.DropDownListElement.EditableElement.TextBox.Fill.BackColor = Color.FromArgb(27, 161, 226);
radDropDownList1.DropDownListElement.EditableElement.ForeColor = Color.White;
}
void
timer1_Tick(
object
sender, EventArgs e)
{
Point pos = radDropDownList1.PointToClient(Cursor.Position);
if
(!radDropDownList1.ClientRectangle.Contains(pos) && !radDropDownList1.DropDownListElement.TextBox.TextBoxItem.HostedControl.ClientRectangle.Contains(pos))
{
((FillPrimitive)radDropDownList1.DropDownListElement.Children[1]).ResetValue(FillPrimitive.BackColorProperty, ValueResetFlags.Local);
radDropDownList1.DropDownListElement.EditableElement.ResetValue(LightVisualElement.BackColorProperty, ValueResetFlags.Local);
radDropDownList1.DropDownListElement.EditableElement.TextBox.ResetValue(RadDropDownTextBoxElement.BackColorProperty, ValueResetFlags.Local);
radDropDownList1.DropDownListElement.EditableElement.TextBox.Fill.ResetValue(FillPrimitive.BackColorProperty, ValueResetFlags.Local);
radDropDownList1.DropDownListElement.EditableElement.ForeColor = Color.Black;
}
}
I hope that you find this information useful.
Regards,
Stefan
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.