Resize TabControl with Page_SizeChanged Event.
All, I am having an issue getting my tabcontrol to resize when the web browser is resized.
Here is the block of code doing the resizing... Basically what I am doing is calculating the percentage of screen change and then attempting to resize the control based on the percentage of screen change. If I don't put in any specific code to do the resizing of the tab control, it resizes the the tab control border only, but none of the content therein gets resized, such as textboxes, labels, and tabs themselves. I have a "UserControl" which has the tab control in it and I add the usercontrol to the root datagrid.
Currently, the below code kind of works, but for some odd reason, the tab control does not size correctly with the page resize. When you shrink the page, the tabcontrol is shrinking a lot more than the rest of the page percentage wise, so that the tab control on full size looks correct, but when shrinking, it no longer fills up the screen and just takes up a small portion of the screen that is left. It almost looks like my mathmatics below is wrong, but it looks right to me.
Any suggestions?
Thanks ahead of time... Maurice
if (e.NewSize.Width < _originalWidth ||
e.NewSize.Height < _originalHeight)
{
PageScale.ScaleX = 1.0;
PageScale.ScaleY = 1.0;
}
else
{
if (e.NewSize.Width / e.NewSize.Height > _originalAspectRatio)
{
PageScale.ScaleY = 1.0;
PageScale.ScaleX = 1.0;
}
else
{
PageScale.ScaleX = e.NewSize.Width / _originalWidth;
PageScale.ScaleY = e.NewSize.Height / _originalHeight;
}
}
double dbl_widthDifference = _originalWidth - e.NewSize.Width;
double dbl_heightDifference = _originalHeight - e.NewSize.Height;double dbl_widthPercent = dbl_widthDifference / _originalWidth;
double dbl_heightPercent = dbl_heightDifference / _originalHeight;double dbl_finalWidth = 1.0 - dbl_widthPercent;double dbl_finalHeight = 1.0 - dbl_heightPercent;
cntrlScaleTransform.ScaleX = dbl_finalWidth;
cntrlScaleTransform.ScaleY = dbl_finalHeight;
m_tabCntrlMainContent.RenderTransform = cntrlScaleTransform;