sde Posted December 17, 2003 Posted December 17, 2003 i am making a basic little text editor. i want to allow the user to make the font bold and italics, or bold and underline at the same time. when i set a FontStyle, it only alows me to set 1. ( bold, itlaic, underline ) and if i set 1, it sets everything else to regular. how can i make a FontStyle both Bold and Italics without a dialog ? Quote codenewbie
*Experts* mutant Posted December 17, 2003 *Experts* Posted December 17, 2003 Dim fs as FontStyle fs = FontStyle.Bold Or FontStyle.Italic Use the keyword Or to combine the values. You might also want to read up MSDN on how it works. :) Quote
Malfunction Posted December 17, 2003 Posted December 17, 2003 Dim fs as FontStyle fs = FontStyle.Bold Or FontStyle.Italic Use the keyword Or to combine the values. You might also want to read up MSDN on how it works. :) Just curious why is it OR instead of AND ? Quote Debug me...
Malfunction Posted December 17, 2003 Posted December 17, 2003 I have another question on the text editor issue. The bold/italic/underline buttons are togglebuttons that can be combined. Now I've added three buttons for left, right and center alignment to my toolbar. These are togglebuttons that can only be selected exclusively. Is there some property I haven't found or do I have to code the behaviour myself? Quote Debug me...
Hamburger1984 Posted December 17, 2003 Posted December 17, 2003 AND would substract the flags in this case... bitwise AND: 111000 AND 000111 -> 000000 if you'd do a bitwise OR the result is the Addition of the flags: 111000 OR 000111 -> 111111 Hope this helps! Andreas Quote
Malfunction Posted December 17, 2003 Posted December 17, 2003 thx again for your help... hope someone can enlighten me on that second matter... Quote Debug me...
sde Posted December 17, 2003 Author Posted December 17, 2003 thanks for the info! usually i can convert vb to c#, .. but i can not get that 'or' to work. here's the code i'm working with. just a simple toolbar click action with a bold and italic button. can someone help me just set one of these to both bold and italics with c# ? System.Drawing.Font currentFont = this.rbFeatures.SelectionFont; System.Drawing.FontStyle newFontStyle = currentFont.Style; if(e.Button == tbbBold) { if (this.rtbFeatures.SelectionFont.Bold == true) { newFontStyle = FontStyle.Regular; } else { newFontStyle = FontStyle.Bold; } } else if ( e.Button == tbbItalics ) { if (this.rtbFeatures.SelectionFont.Italic == true) { newFontStyle = FontStyle.Regular; } else { newFontStyle = FontStyle.Italic; } } Quote codenewbie
Leaders dynamic_sysop Posted December 17, 2003 Leaders Posted December 17, 2003 if(e.Button==toolBarButton1) { int fStyle = (int)FontStyle.Bold + (int)FontStyle.Italic; FontStyle f=(FontStyle)fStyle; richTextBox1.SelectionFont=new Font(richTextBox1.Font.Name,richTextBox1.Font.Size,f); } Quote
sde Posted December 17, 2003 Author Posted December 17, 2003 thank you dynamic. that works great! Quote codenewbie
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.