varsha dodiya

varsha dodiya

  • NA
  • 407
  • 75.4k

access tabpages of tabcontrol in c#

Jul 17 2014 8:19 AM
hi everyone,
i have one form in which i have one tab control .
tabcontrol having 4 tabpages . these tabpages r containing groupbox and other controls .
when i select any tabpage by clicking on it ,it is showing me a correct  component but components are not seems to be activated.
for example if i click tabpage2 there is a datagrid view should show some values in it on loading . i put code in tabpage2_click but it  is not working. help me with tab control
here is what i tried..
private void tabPage3_Click(object sender, EventArgs e)
{
cmd = new SqlCommand("SELECT S_P_name, SUM(S_opn_strp) AS ost,SUM(S_opn_tabs) AS otb, SUM(S_sold_strp) AS sst ,SUM(S_sold_tabs) AS stb,SUM(S_pur_strp) as pst,SUM(S_pur_tabs) as ptb, SUM(S_avail_strp) as ast,SUM(S_avail_tabs) as atb FROM STOCK GROUP BY S_P_name", conn);
conn.Open();
dr = cmd.ExecuteReader();
while (dr.Read())
{
int i = 0;
dataGridView1.Rows.Insert(i);

dataGridView1.Rows[i].Cells["S_P_name"].Value = dr["S_P_name"].ToString();
dataGridView1.Rows[i].Cells["S_opn_strp"].Value = dr["ost"].ToString();
dataGridView1.Rows[i].Cells["S_opn_tabs"].Value = dr["otb"].ToString();
dataGridView1.Rows[i].Cells["S_pur_strp"].Value = dr["pst"].ToString();
dataGridView1.Rows[i].Cells["S_pur_tabs"].Value = dr["ptb"].ToString();
dataGridView1.Rows[i].Cells["S_sold_strp"].Value = dr["sst"].ToString();
dataGridView1.Rows[i].Cells["S_sold_tabs"].Value = dr["stb"].ToString();
dataGridView1.Rows[i].Cells["S_avail_strp"].Value = dr["ast"].ToString();
dataGridView1.Rows[i].Cells["S_avail_total"].Value = dr["atb"].ToString();
i++;
}
conn.Close();




Answers (6)