c# set FontSize of TextBox

时光毁灭记忆、已成空白 提交于 2019-12-03 11:04:26

问题


How would I set the font size of a TextBox in c#. I can get the current size but it does not allow to set it.

public static Form client;
((TextBox)client.Controls[0]).Font.size = 16;

回答1:


You have to set the Font property. Size is a readonly property of Font.

var textBox = (TextBox)client.Controls[0];
textBox.Font = new Font(textBox.Font.FontFamily, 16);


来源:https://stackoverflow.com/questions/13529563/c-sharp-set-fontsize-of-textbox

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!