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

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.