简体   繁体   中英

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 )

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.

Font中的大多数属性只能通过构造函数进行设置,您需要创建一个新的Font实例并将其重新分配给RTB。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM