Sysnative Template Editor Feedback

Code:
richTextBox1.Text.IndexOf("[B]");
richTextBox1.SelectionFont = new Font(richTextBox1.Font.FontFamily, richTextBox1.Font.Size, FontStyle.Bold);

I've made a little test button on the form to test the code with, and I've noticed a slight problem; although the code works fine, once the method becomes true (I assume it's boolean right?), the entire font for the text box becomes bold.

I figured maybe use a variable or something, but then you can't change the font?
 
Code:
richTextBox1.Text.IndexOf("[B]");
richTextBox1.SelectionFont = new Font(richTextBox1.Font.FontFamily, richTextBox1.Font.Size, FontStyle.Bold);

I've made a little test button on the form to test the code with, and I've noticed a slight problem; although the code works fine, once the method becomes true (I assume it's boolean right?), the entire font for the text box becomes bold.

I figured maybe use a variable or something, but then you can't change the font?

The method can't become true; It's just a method, you call it, it doesn't hold a state.

I figured maybe use a variable or something, but then you can't change the font?

What do you mean by this? What do you mean use a variable? :S

All of the variables needed are already pre-defined properties.

If the whole text becomes bold you must be doing something wrong (perhaps all of the text is selected before you change the SelectionFont).
 
Sorry for the slow reply, but I can't remember what I meant now, it's was my friend's last night out in Milton Keynes at the weekend before they go to university to study computer science, so I've forgotten my reasoning about the post.

I think a better idea, would be to take a step back, and then look at each element of that block of code and explain how it works, and then maybe I will be able to understand how to use the .NET Framework better.

Hope you don't mind me asking to learn each element more thoroughly, but at least it will help learn to code :)
 

Has Sysnative Forums helped you? Please consider donating to help us support the site!

Back
Top