DoubleClick in DataGrid

T

Tor Inge Rislaa

DoubleClick in DataGrid

Hi I have a Datagrid bound to a dataset that I want to write a DoubleClick
procedure on. My problem is that the DoubleClick event is raised only when
DoubleClicking the column or row header. How is it possible to get a
DoubleClick event to occur on a row wherever it is DoubleClick. I also want,
when a cell within the row is selected, that the entire row is marked as
selected not just the actual cell.

TIRislaa
 
S

SStory

Tor,

Cells require that you add a handler for each control in the grid and trap
that.

You can make one doubleclick method and
do for each on the controls in the grid and

AddHandler (adding your double click method (handler) ) to handle the
doubleclick event for each of these controls.

hope this isn't too confusing.
I had the same problem and this solves it.

Shane
 
S

SStory

I use this to trap some function keys.

Private Sub SetGridControlKeydownHandlers()
Dim c As Control
For Each c In grdMyGridName.Controls
AddHandler c.KeyDown, AddressOf HandleFunctionKeys
Next
End Sub

Private Sub HandleFunctionKeys(ByVal Sender As Object, ByVal e As
System.Windows.Forms.KeyEventArgs)
'handle form hotkeys F6,F7,F8,F9
If e.KeyCode = Keys.F6 Then
e.Handled = True
'do something
ElseIf e.KeyCode = Keys.F7 Then
e.Handled = True
'do something
ElseIf e.KeyCode = Keys.F8 Then
e.Handled = True
'do something
ElseIf e.KeyCode = Keys.F9 Then
e.Handled = True
'do something
End If
End Sub

call SetGridControlKeydownHandlers()
everytime you refresh the grid data.

Hope this helps you.

Shane
 
B

Banmere

The following code worked for me. It highlights the cell (but not the
row) and made the doubleclick handler of my datagrid run without adding
a handler to each control.

Dim c As Control
For Each c In dgridMain.Controls
c.Enabled = False
Next

Hope this helps someone!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top