To turn bold on and off in a richtextbox in VB6, you did this:
What's the equivalent in .NET?VB Code:
rtbSectionText.SelBold = Not rtbSectionText.SelBold
Thanks.
Printable View
To turn bold on and off in a richtextbox in VB6, you did this:
What's the equivalent in .NET?VB Code:
rtbSectionText.SelBold = Not rtbSectionText.SelBold
Thanks.
Try this:
VB Code:
If RichTextBox1.SelectionFont.Bold Then RichTextBox1.SelectionFont = New Font(RichTextBox1.Font, FontStyle.Regular) Else RichTextBox1.SelectionFont = New Font(RichTextBox1.Font, FontStyle.Bold) End If
Yup :)
Just another thing i've noticed that takes a lot more effort than VB6 :(
Thanks Edneeis :D
Nope :( :( Not quite
I need to turn on / off a single text attribute only; so if text is bold and italic, then add underline, the text should have all 3, then if the user turns off italic, the text will be left bold and underline.
More help?
And why is it so hard in NET, that was so easy in VB6 :confused:
It does seem like its more trouble than it should be, but I wouldn't say its so hard. Most things in .NEt are easier I would say, but not this one.
VB Code:
If RichTextBox1.SelectionFont.Bold Then RichTextBox1.SelectionFont = New Font(RichTextBox1.Font, RichTextBox1.SelectionFont.Style - FontStyle.Bold) Else RichTextBox1.SelectionFont = New Font(RichTextBox1.Font, RichTextBox1.SelectionFont.Style + FontStyle.Bold) End If
I agree, the advantages far outweight the disadvantages, it's just some things that were simple in VB6 (like Buttongroups, Setting / unsetting text attributes and making a lable transparent) seem to be more complicated to do.Quote:
It does seem like its more trouble than it should be, but I wouldn't say its so hard. Most things in .NEt are easier I would say, but not this one.
Can you tell i'm a beginner :p
...and thanks for the code, now it works a treat!