Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DatagridView.CellClick

Status
Not open for further replies.

allanmc10

Programmer
Feb 23, 2006
39
GB
i am trying to single out 2 cells in a datagridview row so i can add additional data into them.

i used the event DatagridView.CellClick but evrytime any cell in the datarow is clicked it brings up the information i want but i only want this to happen in the 2 cells not all cells

Any help would be much appreciated

many thanks

Big Al everbodies pal
 
You could use the cells' index to determine if the cell you want has been clicked:

Private Sub dataGridView1_CellClick(ByVal sender As Object, _
ByVal e As DataGridViewCellEventArgs) _
Handles dataGridView1.CellClick

If e.ColumnIndex = 2 Or e.ColumnIndex = 3 Then
'do some stuff
End If

End Sub

Note that in this line

If e.ColumnIndex = 2 Or e.ColumnIndex = 3 Then

you will of course need to use that actuals indexes of the columns you want.



I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson

Arrrr, mateys! Ye needs ta be preparin' yerselves fer Talk Like a Pirate Day! Ye has a choice: talk like a pira
 
jebenson thank you very much working fine now

regards

Big Al everbodies pal
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top