greep
asked on
C# Windows app. Increase the height of a multiline textbox to show all text entered
Hi
I am new to C# so apologies if this is a silly question.
I have a windows form with a series of textboxes for data input. A few of them are multiline. I need to expand the height of the multiline text box to show all the data that has been input without a scrollbar.
I will also need to move all the controls below the adjusted text box down the form to a new position to avoid overlap.
Any sample code or help would be great!
Thanks in advance!
I am new to C# so apologies if this is a silly question.
I have a windows form with a series of textboxes for data input. A few of them are multiline. I need to expand the height of the multiline text box to show all the data that has been input without a scrollbar.
I will also need to move all the controls below the adjusted text box down the form to a new position to avoid overlap.
Any sample code or help would be great!
Thanks in advance!
One option is to use 'TableLayoutPanel' in the designer which will automatically push the controls down.
Add a TableLayoutPanel to the form in the designer.
Arrange the textboxes and other controls in the rows of that table.
when you increase the height of a multiline textbox, increase the height of the table row as well (like tableLayoutPanel1.RowStyle
Another option is to programatically change the Location of the controls as shown in the code below.
public void MoveControlsBelow(Control control, int moveHeight)
{
foreach (Control c in this.Controls)
{
if (c != control)
{
if (c.Location.Y >= control.Location.Y)
{
c.Location = new Point(c.Location.X, c.Location.Y + moveHeight);
}
}
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I agree with Kris per's solution. That is the best answer.
Regards,
VSS
Regards,
VSS
ASKER
Thanks! Much appreciated!
just drag and drop your controls where you want