I'm trying to get a textbox
to change its height dynamically while maintainign a fixed width
. Cuttently when the text
is too long and goes too a second line the textbox
does not resize
.
The textbox
is sized after all text has been added.
Below is what I'm currently using.
txtwfSupportNotes[i].Multiline = true;
txtwfSupportNotes[i].Text += ds.Tables[0].Rows[i]["Notes"].ToString()
+ "\r\n\r\n";
Size txtSize = TextRenderer.MeasureText(txtwfSupportNotes[i]
.Text, txtwfSupportNotes[i].Font);
txtwfSupportNotes[i].Width = 355;
txtwfSupportNotes[i].Height = txtSize.Height+5;
txtwfSupportNotes[i].BorderStyle = BorderStyle.FixedSingle;
EDIT: Got a fix, see below.
Size txtSize = TextRenderer.MeasureText(txtwfSupportNotes[i].Text, txtwfSupportNotes[i].Font, txtwfSupportNotes[i].ClientRectangle.Size, TextFormatFlags.WordBreak);
txtwfSupportNotes[i].Height = txtSize.Height+5;