Textbox property

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

if i have a textbox and want to change the text inside the textbox into
(blod-italic)
using buttons

i try this
textbox1.font=font.italic; \\ for the button italic
and its not work

and give me error-> can'y implicitly convert type bool to system.drawing .font
plz someone tell me how and why?
 
Islam,

When you say 'Font.Italic', you are returning the boolean Italic
property from the Font property that is exposed.

Rather, what you want to do is:

textbox1.Font.Italic = true;

Hope this helps.
 
SemSem said:
if i have a textbox and want to change the text inside the textbox into
(blod-italic)
using buttons

i try this
textbox1.font=font.italic; \\ for the button italic
and its not work

and give me error-> can'y implicitly convert type bool to system.drawing
.font plz someone tell me how and why?

Font font = new Font(textBox1.Font, System.Drawing.FontStyle.Bold |
System.Drawing.FontStyle.Italic);
textBox1.Font = font;
 
Nicholas said:
Islam,

When you say 'Font.Italic', you are returning the boolean Italic
property from the Font property that is exposed.

Rather, what you want to do is:

textbox1.Font.Italic = true;

Hope this helps.

Isn't the .Italic property on Font read-only?
 
Oops, that's wrong, the Bold property is read-only. See Tom's response
for the correct answer.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Nicholas Paldino said:
Islam,

When you say 'Font.Italic', you are returning the boolean Italic
property from the Font property that is exposed.

Rather, what you want to do is:

textbox1.Font.Italic = true;

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

SemSem said:
if i have a textbox and want to change the text inside the textbox into
(blod-italic)
using buttons

i try this
textbox1.font=font.italic; \\ for the button italic
and its not work

and give me error-> can'y implicitly convert type bool to system.drawing
.font
plz someone tell me how and why?
 
Back
Top