KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm writing a program where the user should be able to write text in a TextBox . I'd like the TextBox to resize itself, so it fits to the content. I've tried the following: private void textBoxTitle_TextChanged(object sender, TextChangedEventArgs e) { System.Drawing.Font myFont = new System.Drawing.Font("Verdana", 8); System.Drawing.SizeF mySize = e.Graphics.MeasureString("This is a test", myFont); this.textBoxTitle.Width = (int)Math.Round(mySize.Width, 0); } I get an error saying that Graphics doesn't work for TextChangedEventArgs . Is there another way I can resize the TextBox ?
Tags (comma-separated)
Save Edits
Cancel