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();

varsha dodiyaPosted Jul 19, 2014, 2:49 AM
varsha dodiyaPosted Jul 18, 2014, 5:43 AM
Lakshmanan Sethu SankaranarayanPosted Jul 18, 2014, 4:15 AM
I couldnt see the attachment. can you please check?
varsha dodiyaPosted Jul 18, 2014, 2:18 AM
just help me with tab control rest all is is working acc. to me.
I have tabcontrol in which there are 4 tabpages. there are different control in these tabpage but they are not working when i open any tabpage on click. i need to click again somewhere on that tabpage then controls seems working .
i have attached image of form ..
in which u can see there are some tabpages for ex. when i click tab view opening Stock tabpage the grid should start working by filling data in it.but i need to click on that tabpage (outside groupbox) then grid starts working n fills datavalues in it.
what i want is i dont have to click again on that tabpage to make work my controls on that tabpage..
thank u for reading it .
Ramesh MaruthiPosted Jul 17, 2014, 10:24 AM
I think its a wrong question or you might be declare some where in ur program where did u declare cmd and dr ?
can u try it declaring cmd and dr
using (var conn = new SqlConnection(SomeConnectionString))
using (var cmd = conn.CreateCommand())
{
conn.Open();
cmd.CommandText = "SELECT * FROM learer WHERE id = @id";
cmd.Parameters.AddWithValue("@id", index);
using (var dr= cmd.ExecuteReader())
{
if (dr.Read())
{
learerLabel.Text = dr.GetString(reader.GetOrdinal("somecolumn"))
}
}
}
And I didn't understand this line
dataGridView1.Rows.Insert(i); /// what your trying to do here varsha i is nothing but a int and its value is zero ?
can you modifiy that line as
in i = dataGridView1.Rows.Add();
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++
vamsidhar kotipalliPosted Jul 17, 2014, 9:16 AM
Try to make your tab2 controls on tabpage2_click. or i can suggest if you go with client side will easy to manage the controls (if it meet you Environment)