Click here to Skip to main content
15,888,271 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
hai,
i am working on c#.net application ,in my application i have one tabcontrol in that three tabs now my requirement is how switch one tab to another
Posted
Comments
Thanks7872 10-Oct-14 7:53am    
Do you have habit of posting point less questions? It sounds some what harsh but i really wanna know. Why posting requirements all the time? Why not a question?

What have you tried? Where is the code you have implemented till now?

Don't dump your code as comment here. If you want help, update the question with the same.

If switching tabs programmatically is what you are asking for, then to switch to tabPage2:
C#
this.tabControl1.SelectedIndex = tabControl1.TabPages.IndexOf(this.tabPage2);
 
Share this answer
 
i got answer to my question

public void view_load_lkg_to_seventh()
{
//this code for auto resize of columns
dataGridView1.AutoResizeColumns();
dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;


ConnectionStringSettings consettings = ConfigurationManager.ConnectionStrings["smssms"];
string connectionString = consettings.ConnectionString;
SqlConnection cn = new SqlConnection(connectionString);

SqlCommand sqlcmd = new SqlCommand();
SqlDataAdapter da = new SqlDataAdapter();
DataTable dt = new DataTable();

cn.Open();
//pass query

sqlcmd = new SqlCommand(@"select * from lkg_to_seventh_marks ", cn);
da = new SqlDataAdapter(sqlcmd);
//Fill the data in the SQL Data Adapter
da.Fill(dt);
//Bind it in the DataGrid View
dataGridView1.DataSource = dt;
cn.Close();
}
public void view_load_tenthclass_marks()
{
//this code for auto resize of columns
dataGridView3.AutoResizeColumns();
dataGridView3.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;


ConnectionStringSettifdgngs consettings = ConfigurationManager.ConnectionStrings["smssms"];
string connectionString = consettings.ConnectionString;
SqlConnection cn = new SqlConnection(connectionString);

SqlCommand sqlcmd = new SqlCommand();
SqlDataAdapter da = new SqlDataAdapter();
DataTable dt = new DataTable();

cn.Open();
//pass query

sqlcmd = new SqlCommand(@"select * from tenthclass_marks ", cn);
da = new SqlDataAdapter(sqlcmd);
//Fill the data in the SQL Data Adapter
da.Fill(dt);
//Bind it in the DataGrid View
dataGridView3.DataSource = dt;
cn.Close();
}
C#
private void tabControl1_Click(object sender, EventArgs e)
           {
               if
           (tabControl1.SelectedTab == tabPage2)
               {
                   view_eighth_to_ninth_marks();
               }
               else
                   if (tabControl1.SelectedTab == tabPage1)
                   {   view_load_lkg_to_seventh();
               }
               else if(tabControl1.SelectedTab == tabPage3)

               {
                view_load_tenthclass_marks();
               }

}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900