adil sharif
adil sharif

Reputation: 55

datagridview double click event

I'm new to programming. I have a form (named personal_Info) that fills some person's personal data and saves it in the database table Personal_Information.

2nd I have another form that searches from Personal_Information and shows results in a grid view.

I now want: When search result show in data grid view and when I double click on any row of the shown results I want (personal_info) to open and make an edit at that form and save it.

Please help me.

here is little code which gets data from sql to grid

SqlConnection strconn = new SqlConnection("server=AAG-PC; Database=humanResource; Integrated Security=sspi"); 
strconn.Open(); 
SqlCommand strcmd = new SqlCommand("select * from Personal_Information where "
+ searchComboBx.SelectedItem
+ " like '%" + txtBxKeyword.Text.Trim() + "%'", strconn); 
SqlDataAdapter ad = new SqlDataAdapter(strcmd); 
DataSet ds = new DataSet (); 
ad.Fill(ds); 
strconn.Close(); 
gridViewSearchResult.DataSource = ds.Tables[0];

Upvotes: 0

Views: 101

Answers (1)

Orifjon
Orifjon

Reputation: 1097

You can use dataadapter to update your changes. It will be something like

changes = ds.GetChanges();
if (changes != null)
{
     adapter.Update(changes);
}

you can see more info here

Upvotes: 1

Related Questions