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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

forms keydown does not fire when datagrid cell is active 1

Status
Not open for further replies.

Blitz

Technical User
Jul 7, 2000
171
US
What do i need to do so that when a datagrid cell is active and F8 is pressed it will fire the keydown event of my form? Also why is it that a custom columnstyle (similar to a combobox column) does fire the forms keydown event but a standard textboxcolumn does not?
 
The following code loops through all columns in a datagrids table style and wires up an event handler to the text box of the column style. You can then use the event handler to capture an F8 key down...

Call the Test sub after the grid is bound.

Code:
    Private Sub Test()

		Dim gcs As DataGridColumnStyle

		For Each gcs In DataGrid.TableStyles(0).GridColumnStyles

			If TypeOf gcs Is DataGridTextBoxColumn Then

				AddHandler CType(gcs, DataGridTextBoxColumn).TextBox.KeyDown, AddressOf TestHandler

			End If

		Next

	End Sub

	Private Sub TestHandler(ByVal sender As Object, ByVal e As KeyEventArgs)

		If e.KeyCode = Keys.F8 Then

			'Do whatever

		End If

	End Sub
 
Thank you, this should work perfectly.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top