By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,383 Members | 2,070 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,383 IT Pros & Developers. It's quick & easy.

Datagridview keypress event question

P: n/a
Bob
In that event, how can you find out if the keypress event was in a certain
column? Say you have datagridview1, columnname1, columnName2
You want to do something only with the keypress event of column2, do nothing
special with column1

Private Sub Datagrid1_KeyPress(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles Datagrid1.KeyPress

If Me.datagrid1......... Then - how do you specify its for column2,
can't find the way via intellisense properties

End If

End Sub

Thanks for any help

Bob


Jan 11 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Bob
Found it!
Its
If Me.DataGRidview1.CurrentCell.OwningColumn.DataProp ertyName =
"MyDataPropertyName" Then

Talk about going around incircles to get something done !
hehehe

Bob
"Bob" <bd*****@sgiims.com> wrote in message
news:%2***************@TK2MSFTNGP11.phx.gbl...
In that event, how can you find out if the keypress event was in a certain
column? Say you have datagridview1, columnname1, columnName2
You want to do something only with the keypress event of column2, do
nothing special with column1

Private Sub Datagrid1_KeyPress(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles Datagrid1.KeyPress

If Me.datagrid1......... Then - how do you specify its for column2,
can't find the way via intellisense properties

End If

End Sub

Thanks for any help

Bob


Jan 11 '06 #2

P: 1
Hello Bob,
This was what I was looking for..BUT they datagridview keypress handler won't respond if you edit a cell in that particular colum. I only can make it work when editing in the first column. Any ideas?

thanks
Sean

Private Sub DataGridView1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles DataGridView1.KeyPress

With DataGridView1
If .CurrentCell.OwningColumn.DataPropertyName = "Name" Then
If e.KeyChar = "1" Then
'do something
End If
End If
End With

End Sub

Found it!
Its
If Me.DataGRidview1.CurrentCell.OwningColumn.DataProp ertyName =
"MyDataPropertyName" Then

Talk about going around incircles to get something done !
hehehe

Bob


"Bob" <bdufour@sgiims.com> wrote in message
news:%23QUJaPvFGHA.344@TK2MSFTNGP11.phx.gbl...[color=blue]
> In that event, how can you find out if the keypress event was in a certain
> column? Say you have datagridview1, columnname1, columnName2
> You want to do something only with the keypress event of column2, do
> nothing special with column1
>
> Private Sub Datagrid1_KeyPress(ByVal sender As Object, ByVal e As
> System.Windows.Forms.KeyPressEventArgs) Handles Datagrid1.KeyPress
>
> If Me.datagrid1......... Then - how do you specify its for column2,
> can't find the way via intellisense properties
>
>
>
> End If
>
> End Sub
>
> Thanks for any help
>
> Bob
>
>
>
>
>
>[/color]
Mar 22 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.