problem in change values of datagridview using c#
Hello every one,
well i have one problem i have combo box which is bind from the database. when the user select from combo box after that focus should be cell number 3 of datagrid view i dont know which event should be used for it and what is the code for it. hope you understand what i want
thanks in Advance

Nilanka DharmadasaPosted Nov 12, 2009, 4:04 AM
What do you mean by cell 3?
Anyway, let's say you want to select cell with rowindex 2 and column index 3. And the name of datagridview is 'datagrid'.
Then try this code.
daniel rajPosted Jun 21, 2010, 1:12 AM
Kirtan PatelPosted Nov 12, 2009, 6:45 AM
you can not Directly Add new item to Combo box that is Bound to Some Database items
but you need to insert One Extra Row in Ds.Table[0] Which Will Contain this "Select party Name" before Binding ds.Table[0] to Combo Box
Code like Below
private void get_party_details()
{
cb_party_name.Items.Add("Select Party Name");
try
{
DataSet ds = new DataSet();
ds = gBL.show_party_details_name();
//Insert Row Here
DataRow r = new DataRow();
// Here Instad of r[3] use the Index of Column "Party Name" according to your Database Table Structure
r[3] = "Select Party Name";
ds.Tables[0].Rows.InsertAt(r, 0);
//After Adding New Row Now you can bind and It Will Show "Select Party Name in Combobox :)
cb_party_name.DataSource = ds.Tables[0];
cb_party_name.DisplayMember = "Party_Name";
}
catch (Exception)
{
//MessageBox.Show("Error!: " + ex.Message.ToString() + ". Please contact PSR Computers for Support");
}
if my answer Helps you then Check "Do you like this answer check box " :)
Naeem KhanPosted Nov 12, 2009, 5:30 AM
Nilanka DharmadasaPosted Nov 12, 2009, 4:50 AM
//In your combo box selected index changed event, write this
datagrid.CurrentCell = datagrid.CurrentRow.Cells[3];
//Then do the calcualtion
datagrid.CurrentCell = datagrid.CurrentRow.Cells[5];
Nilanka DharmadasaPosted Nov 12, 2009, 4:39 AM
My code is not working for you?
If so paste you code here. Ill give you the exact solution. :)
Naeem KhanPosted Nov 12, 2009, 4:15 AM
Naeem KhanPosted Nov 12, 2009, 3:09 AM