Bohn
Bohn

Reputation: 26919

Changing font at run-time

Looking at some old VB 6.0 code we had created a global mFont variable and on Form_Load we had said richTextbox.Font = mFont, then later in code that there is a toolbar button to increase the font size we had just increased the size but did not have to do richTextbox.Font = mFont one more time. It was just doing it, but looks like in C# is it different? each time I change that font size do I have to assign it again so it takes effect? ( assuming still I have assgined richTextBox.Font = mFont at Form_Load event )

Upvotes: 0

Views: 542

Answers (2)

competent_tech
competent_tech

Reputation: 44921

Most of the properties in Font are only settable through the constructor, you would need to create a new Font instance and reassign that to the RTB.

Upvotes: 1

Robert Levy
Robert Levy

Reputation: 29073

Yes that is correct. You need to set the Font property to a new Font object whenever you want to change any aspect of the font.

Upvotes: 1

Related Questions