Usually you would typically derive from a base form which derived from Form. In this class you would handle the SIP EnabledChanged event and resize the tab control or another other control that wasn’t using any type of anchoring/docking.
You would normally have coded something like this:
private void sip_EnabledChanged(object sender, EventArgs e)
{
Resize();
}
The above is still relevant if you are targeting CF 1.0. However you might want to extend the Resize method to support other controls in CF 1.0 as CF 1.0 has no support for Anchoring or docking.
private void Resize()
{
try
{
if (Visible)
{
foreach (Control ctl in Controls)
{
if (ctl.GetType() == typeof(TabControl))
{
//Set the height of the tab control.
Rectangle rect;
rect = this.ClientRectangle;
ctl.Height = rect.Height + 2 * 96 /
CurrentAutoScaleDimentions.Width;
ctl.Width = rect.Width;
}
}
}
}
catch { }
}
Note the use of property CurrentAutoScaleDimensions.Width - this gives us access to the DPI to which the form is rendered. Quite neat addition back when CF 2.0 was released.
Happy coding :)
No comments:
Post a Comment