views:

37

answers:

1

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);
        }
    }
+1  A: 

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.

Itay
Thanks but it only worked at this scenario: the FIRST time that I assign say Label1 to the Label property of my custom comboBox .. it works... but now if like any other control I go and change the Text property of Label1 by modifying its Text property ... then it does not add the asterisk to this new text. Keeps the bold tho.
BDotA
but I guess it is OK for now. better than not working at all :) Thanks
BDotA
I have updated the reply to response your comment
Itay