Super-lightweight WinForms TabControl
-
This is a tab control without tabs for those who don't need them (eg when the
SelectedIndex
property is set programmaticaly).public class NoTabControl : ContainerControl
{
private int selectedIndex = -1;public int SelectedIndex { get { return selectedIndex; } set { if (value < 0 || value >= Controls.Count) throw new ArgumentOutOfRangeException(); if (selectedIndex != -1) Controls\[selectedIndex\].Visible = false; selectedIndex = value; Controls\[selectedIndex\].Visible = true; } } protected override void OnControlAdded(ControlEventArgs e) { base.OnControlAdded(e); e.Control.Visible = false; }
}
Not sure if it is wicked enought for this forum but can be useful anyway.
Greetings - Jacek
-
This is a tab control without tabs for those who don't need them (eg when the
SelectedIndex
property is set programmaticaly).public class NoTabControl : ContainerControl
{
private int selectedIndex = -1;public int SelectedIndex { get { return selectedIndex; } set { if (value < 0 || value >= Controls.Count) throw new ArgumentOutOfRangeException(); if (selectedIndex != -1) Controls\[selectedIndex\].Visible = false; selectedIndex = value; Controls\[selectedIndex\].Visible = true; } } protected override void OnControlAdded(ControlEventArgs e) { base.OnControlAdded(e); e.Control.Visible = false; }
}
Not sure if it is wicked enought for this forum but can be useful anyway.
Greetings - Jacek
-
Huh? Why would you use a control for something you dont need?
xacc.ide
IronScheme - 1.0 beta 3 - out now!
((lambda (x) `((lambda (x) ,x) ',x)) '`((lambda (x) ,x) ',x))leppie wrote:
Why would you use a control for something you dont need?
I think you misunterstood me. By "tab" I meant a clickable area with a title which is used to switch between panels. Panels in the NoTabControl can be switched programmaticaly, but no actual tabs are rendered.
Greetings - Jacek
-
This is a tab control without tabs for those who don't need them (eg when the
SelectedIndex
property is set programmaticaly).public class NoTabControl : ContainerControl
{
private int selectedIndex = -1;public int SelectedIndex { get { return selectedIndex; } set { if (value < 0 || value >= Controls.Count) throw new ArgumentOutOfRangeException(); if (selectedIndex != -1) Controls\[selectedIndex\].Visible = false; selectedIndex = value; Controls\[selectedIndex\].Visible = true; } } protected override void OnControlAdded(ControlEventArgs e) { base.OnControlAdded(e); e.Control.Visible = false; }
}
Not sure if it is wicked enought for this forum but can be useful anyway.
Greetings - Jacek