Thursday, July 30, 2009

Visual Studio 2005 - Using Code - Both Bold And Italic @ the same time?

I'm using visual studio 2005, i'm doing a project in college and fairly new to the program. i'm using visual basic language (no C,c++,java, ect)





I have code to change my textbox to bold or italic, ect.


however i can not get the code to use both - i have tried various different approachs. all have failed.





TextBox1.Font = New System.Drawing.Font(TextBox1.Font, FontStyle.Bold)





is what i have to make it bold, i have tried all the following with no success


'1


TextBox1.Font = New System.Drawing.Font(TextBox1.Font, FontStyle.Bold and Fontstyle.italic)





'2


TextBox1.Font = New System.Drawing.Font(TextBox1.Font, FontStyle.Bold %26amp; Fontstyle.italic) 'WTF this one made it have strikethrough and be underlined - VERY wierd!





'3


TextBox1.Font = New System.Drawing.Font(TextBox1.Font, FontStyle.Bold)


TextBox1.Font = New System.Drawing.Font(TextBox1.Font, FontStyle.italic)





'4


TextBox1.Font = New System.Drawing.Font(TextBox1.Font, FontStyle.Bold, Fontstyle.italic)








I've tried a few others but all have had no success. Any help would be Greatly Apreciated.

Visual Studio 2005 - Using Code - Both Bold And Italic @ the same time?
TextBox1.Font =


New System.Drawing.Font


(TextBox1.Font,


FontStyle.Bold + FontStyle.Italic)





This is all one line. I broke it down so it wouldn't get cut off.
Reply:TextBox1.Font.Bold = True


TextBox1.Font.Italic = True
Reply:New System.Drawing.Font(textbox1.font, CType((FontStyle.Bold Or FontStyle.Italic), System.Drawing.FontStyle)





Should work. Hope that helps


No comments:

Post a Comment