Cannot change the Label text!

Posted by BDotA on Stack Overflow See other posts from Stack Overflow or by BDotA
Published on 2010-06-18T15:05:17Z Indexed on 2010/06/18 15:13 UTC
Read the original article Hit count: 363

Filed under:
|
|

I have created a custom control and added a label property to it so at design time we can pick a Label and assign it to that control. so basically I want that if a label is assigned to that control, its text should change as below and also its text should change to bold font, so here is that code:

private Label assignedLabel;
public Label AssignedLabel
{
    get
    {
        return assignedLabel;
    }
    set
    {
        assignedLabel = value;
        assignedLabel.Text = @"*" + assignedLabel.Text; 
        assignedLabel.Font = new Font(AssignedLabel.Font, FontStyle.Bold);
        AssignedLabel.Refresh();
    }
}

the problem is that based on the code above the Font of that assigned label is correctly changing to Bold font, but its Text is not taking affect. why is that happening? how can I fix this issue?

© Stack Overflow or respective owner

Related posts about c#

Related posts about winforms