|
Post by PlayunJayun on Oct 31, 2003 12:04:59 GMT -5
Hi all,
I am a newbie here and would really like some help.
I have created a checkBox for emboldening a string of text contained in a label control within a form, but I am having a few problems making the reverse happen when the box is unchecked.
I have been looking on the msdn site, although I can't seem to locate the right section to help me.
Out of the various solutions I have tried, I think this seems to be nearest the actual solution although it will not compile as c# doesn't like the ! before the FontStyle.Strikeout.
private void checkBox4_CheckedChanged(object sender, System.EventArgs e)
{ if (checkBox4.Checked) { label1.Font = new Font (label1.Font, label1.Font.Style |FontStyle.Bold); } else { label1.Font = new Font (label1.Font, label1.Font.Style |!FontStyle.Bold); }
Much thanks to anyone who can forward any ideas,
PJ :)
|
|
Sharq
New Member
Posts: 2
|
Post by Sharq on Jan 4, 2004 15:36:23 GMT -5
Hi I've got some simple but not nice solution for you First I created a private obejct obj and then I clone to it current (regular) font in the end of InitializeComponent br] obj = label1.Font.Clone(); then modify a bit your code so now it look like this br]if (checkBox1.Checked) { label1.Font = new Font (label1.Font, label1.Font.Style |FontStyle.Bold ); } else { label1.Font = (System.Drawing.Font)obj; } Propably it is not a best solution but it come first to my mind and it works so if u don't have any other ideas u can use it Sharq PS If you still have got problems with understanding my code I can send you a working sample
|
|