Jordan Trainor
Jordan Trainor

Reputation: 2438

c# set FontSize of TextBox

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;

Upvotes: 31

Views: 94612

Answers (1)

user27414
user27414

Reputation:

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);

Upvotes: 63

Related Questions