Reputation: 189
I have inherited code that includes a Windows Form that contains a TabControl with 5 tabs. I can't switch tabs in the designer. When I open the form in design view, the first tab is selected, and the contents of the first TabPage is displayed. When I try to switch tabs, the correct tabs at the top are selected, but only the first TabPage is displayed. I can add tabs to the control, but they don't display with an empty TabPage to work with. How can I switch tabs in the designer view so I can modify the content of the second or third TabPage?
Upvotes: 0
Views: 2062
Reputation: 11
crooked-handed programmers did not foresee this :) add prop in editor ActiveTab
public class ExTabControl : TabControl
{
private const int TCM_ADJUSTRECT = 0x1328;
private bool showBtn = false;
private Message mes;
public int? ActiveTab
{
get
{
if (this.TabPages.Count == 0 || this.SelectedTab == null)
return null;
return this.TabPages.IndexOf(this.SelectedTab);
}
set
{
if (this.TabPages.Count > 0 )
{
var _value = Math.Max(value ?? 0, 0);
var v = Math.Min(_value, this.TabPages.Count - 1);
this.SelectedTab = this.TabPages[v];
}
}
}
[DefaultValue(false)]
public bool ShowBtn
{
get => showBtn;
set
{
showBtn = value;
WndProc(ref mes);
}
}
protected override void WndProc(ref Message m)
{
mes = m;
if (m.Msg == TCM_ADJUSTRECT && !showBtn)
{
m.Result = (IntPtr)1;
return;
}
base.WndProc(ref m);
}
}
Upvotes: 1
Reputation: 21
Click on TabControl in WindowsForm. Go to Properties>TabPages. On the left side, you will see tabs listed, there will be 2 arrows next to them, using the arrow, take the tab you want to view/edit to the top and click Ok. This should solve your issue for now.
Upvotes: 0