Hello gurus, I have a little problem here that I'm sure one of you could easily solve. I'm creating my datagridview dynamically using the dataset from my sql query. What I want to do is to associate my DataGridViewImageColumn on each row with a click event. I'm not sure how to do this but I'm certain it could be done via code. Since the grid view doesn't get created until a userID is selected, I am unable to click on the image to expose a click event. Here is the relevant part of my code.
if (cbPatientID.SelectedIndex > 0) { radioButton1.Visible = false; radioButton2.Visible = false; tabControl1.TabPages.Remove(Options); tabControl1.TabPages.Remove(Profiles); if (cbPatientID.SelectedIndex == 1) { Form f2 = new CreatePatientRecord(); this.Hide(); f2.ShowDialog(); this.Close(); } else { radioButton1.Visible = true; radioButton2.Visible = true; BGGridView.Visible = true; BPGridView.Visible = true; FoodGridView.Visible = true; InsPumpGridView.Visible = true; Image editimg = Properties.Resources.editor; Image delimg = Properties.Resources.del; DataGridViewImageColumn btnEditBG = new DataGridViewImageColumn(); DataGridViewImageColumn btnDelBG = new DataGridViewImageColumn(); btnEditBG.HeaderText = "Edit"; btnDelBG.HeaderText = "Delete"; btnEditBG.Image=editimg; btnDelBG.Image=delimg; BGGridView.Columns.Add(btnEditBG); BGGridView.Columns.Add(btnDelBG); btnEditBG.Width = 30; btnDelBG.Width = 30;
Microsoft Certified Professional