I have a user control that contains a radlabel and a radmaskedtextbox. I need to change the backcolor of the textbox to match the forecolor of the radlabel when the user control is disabled. Everything works fine if the user control is initially enabled. However, If I set the initial state of the user control disabled, then upon running the program, the maskedtextbox's backcolor is black while the forecolor of the radlabel is gray. Here is the code:
Color disableColor;
private
void
maskedTextBox_EnabledChanged(
object
sender, EventArgs e)
{
if
(!
this
.maskedTextBox.Enabled)
{
//Set disable color the same as the label text color
this
.radLabel.LabelElement.VisualState =
"RadLabelElement.Disabled"
;
disableColor =
this
.radLabel.LabelElement.ForeColor;
//Change the backcolor of the maskedtextbox
this
.maskedTextBox.MaskedEditBoxElement.TextBoxItem.BackColor = disableColor;
}
else
{
//Reset values
}
}
}