datagridview columns inquiry
hi,
im new to vs2005. Is this posible to resize the columns and im using c#? 2nd question is how to make a eventhandler of my button inside the columns?
Code:
dataset ds = new dataset();
MySqlDataAdapter myadapter = new MySqlDataAdapter();
myadapter.SelectCommand = new MySqlCommand();
myadapter.SelectCommand.Connection = stsqcon.getConnection();
myadapter.SelectCommand.CommandText = " Select * from ....";
myadapter.SelectCommand.Parameters.Add("?veh_code",MySqlDbType.Int32 ,4);
myadapter.SelectCommand.Parameters["?veh_code"].Value = lv1.SelectedItems[0].SubItems[1].Text;
myadapter.Fill(ds,"element1");
datagridview1.DataSource = ds;
datagridview1.DataMember = "element1";
Thanks,
Popskie
Re: datagridview columns inquiry
The DataGridView has a Columns property, and each DataGridViewColumn in the collection has a Width property. I don't know about the Buttons, but they are just regular Button objects so I guess you could go through the Controls property of the DataGridView and attach event handlers to each Button. There may well be a better way than that though.
Re: datagridview columns inquiry
Ok thanks jm i try that. But what if i use a datareader,how do i put that data to datagridview.
thanks,
Popskie
Re: datagridview columns inquiry
I would say you'd be best to populate a DataTable and bind it, but I'm afraid I'm not really all that familiar with the DataGridView yet.
Re: datagridview columns inquiry
Anyone knews how to put data into a datagridbiew using
Quote:
datagridview1.Rows.Add();
thanks in advance
Popskie