0

I'm trying to make my rich text box resize with the window as it is resized. So, if you make the window bigger, the text box will become bigger as well, so that it is always filling the window. Here is my code, but when I resize the window nothing happens. I have setup my event handlers properly.

void Form1_ResizeBegin(Object^ sender, EventArgs^ e)
{
	this->formHeightBefore = this->Size.Height;
	this->formWidthBefore = this->Size.Width;
	this->contentBoxWidthBefore = this->Size.Width;
	this->contentBoxHeightBefore = this->Size.Height;
}

void Form1_ResizeEnd(Object^ sender, EventArgs^ e)
{
	this->ContentBox->Size = *new Drawing::Size(this->contentBoxHeightBefore+(this->Size.Height-this->formHeightBefore), this->contentBoxWidthBefore+(this->Size.Width-this->formWidthBefore));
}

Any help would be greatly appreciated.

Regards,
Moshe

Edited by moteutsch: n/a

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by Milton Neal
0

Hi Moshe
A) If the RichTextBox is filling the entire form you can set the Dock property of the RTB to "Fill" and the size of the RTB will risize with the form.
B) Or you can resize it this way:
Get the size of the form's window before the resize.
Get the size of the form's window after the resize.
Get the difference and apply it to the size of RTB.

Cheers
Milton

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.