Reputation: 26919
I have created a custom combobox that has a LABEL property so when we drop it on a form, we can say the Label associated with this ComboBox is say Label2 this is what I wrote for its label property. The whole thing I want to do is that when I am assigning the Label property of my custom ComboBox to one of the labels on the form, I want that label to change its font to bold and also add an "*" to its Test property. thats it ... but it does not work! any ideas?
private Label assignedLabelName;
public Label AssignedLabelName
{
get
{
return assignedLabelName;
}
set
{
assignedLabelName = value;
assignedLabelName.Text = "*" + assignedLabelName.Text;
assignedLabelName.Font = new Font(AssignedLabelName.Font, FontStyle.Bold);
}
}
Upvotes: 0
Views: 438
Reputation: 18286
Try to add a call to
assignedLabelName.Refresh()
at the end of the setter
and - as a reply to your comment How about having a Custom Label too this custom label will hold a flag telling if it is bound to any combo box. The text will be saved in private member and the Text property will return the value of the private text member + an asterisk in case the flag is set.
Upvotes: 1