hi guys,
i have three buttons and three tabpages.
each button displays each tabpage.
like but1, but2, but3.
but1 displays tab1, but diaplays tab2 and but3 displays tab3.
if but1 diaplays tab1 and but2 displays tab2 and but3 displays tab3 by clicking in order from but1,but2 and but3. they are displaying in order. and again if i press but2 it displays(comes to from) tab2 that already displayed. like other 2 buttons does the same...
but
when but2 is clicked first, tab2 is displaying and but1 clicked tab1 displaying and but3 clicks tab3 displayes.. here the order is tab2>tab1>tab3.
as per the rule, if but1 is cliked now, tab1 should be displayed, but2 display tab2 and but3 displays tab3.... but here what is happening is...... if the order is tab2>tab3>tab1. and but1 is pressed tab2 is coming front, but2 is pressed, tab3 is coming front, and but3 is pressed tab1 is coming front... the code i written to do so is..
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace ttr
{
public partial class Form1 : Form
{
TabPage languages = null;
TabPage education = null;
TabPage job = null;
public Form1()
{
InitializeComponent();
tabControl1.Visible = false;
}
private void button1_Click(object sender, EventArgs e)
{
tabControl1.Visible = true;
var contentControl = new tta();
contentControl.Dock = DockStyle.Fill;
var page = new TabPage("Languages");
if (languages == null)
{
languages = new TabPage("Languages");
page.Controls.Add(contentControl);
tabControl1.TabPages.Add(page);
tabControl1.SelectedTab = page;
}
else
{
tabControl1.SelectedTab = languages;
tabControl1.SelectedIndex = 0;
}
}
private void button2_Click(object sender, EventArgs e)
{
tabControl1.Visible = true;
var contentControl = new hhh();
contentControl.Dock = DockStyle.Fill;
var page = new TabPage("Education");
if (education == null)
{
education = new TabPage("Education");
page.Controls.Add(contentControl);
tabControl1.SelectedTab = page;
tabControl1.TabPages.Add(page);
}
else
{
tabControl1.SelectedTab = education;
tabControl1.SelectedIndex = 1;
}
}
private void button3_Click(object sender, EventArgs e)
{
tabControl1.Visible = true;
var contentcontrol = new job();
contentcontrol.Dock = DockStyle.Fill;
var page = new TabPage("Job Titles");
if (job == null)
{
job = new TabPage("Job Titles");
page.Controls.Add(contentcontrol);
tabControl1.SelectedTab = page;
tabControl1.TabPages.Add(page);
}
else
{
tabControl1.SelectedTab = job;
tabControl1.SelectedIndex = 2;
}
}
}
}
please help to display tab pages according to button, but not through the index....