DataGrid_KeyUp event not fired??

D

DraguVaso

Hi,

I'm having a DataGrid in which I want to control the behaviour of my
Arrow-Keys. Unfortunately I'm not able to catch these events. I thought the
KeyUp/Keydown/KeyPress-events, but these are only fired when the DataGrid
isn't editable.

Does anybody knows how I can catch the Arrow-Keys when navigating through a
DataGrid?

Thanks in advance,

Pieter
 
C

Cor

Hi Pieter,

How did you make it not editable using the readonly or using enable = false?

Cor
 
D

DraguVaso

Using enable = false in the Edit.
but that doesn't really matter I guess, because when it's not enabled I get
the KeyUp working.
But when I can edit the cells, I'm not able to trigger the KeyUp-Event...
 
C

Cor

Hi Pieter,

Yes I did want to know that, because I think there are two problems, I give
you a sample I made some days ago, however I did not know if I had sended
that to you. I changed something in it (datagrid.readonly = true). You
should be able with this sample to get the textboxes events. I used the
mouse enter in this sample, because that looks so nice, but I did use it
also with other events. (That dv I use to prevent the last row in the
datagrid).

I hope this helps?


\\\
Private WithEvents dtbCol1 As DataGridTextBox
Private ToolTip1 As New ToolTip
')
Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Datagrid1.ReadOnly = True
Dim ts As New DataGridTableStyle
ts.MappingName = ds.Tables(0).TableName
Dim column As New DataGridTextBoxColumn
ts.GridColumnStyles.Add(column)
DataGrid1.TableStyles.Add(ts)
column = CType(ts.GridColumnStyles(0), DataGridTextBoxColumn)
dtbCol1 = DirectCast(column.TextBox, DataGridTextBox)
column.MappingName = ds.Tables(0).Columns(0).ColumnName
column.HeaderText = "Cor"
column.Width = 30
dv = New DataView(ds.Tables(0))
dv.AllowNew = False
DataGrid1.DataSource = dv
End Sub
Private Sub dtbCol1_ToolTip(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles dtbCol1.MouseEnter
ToolTip1.SetToolTip(DirectCast(sender, DataGridTextBox), _
"Row: " & DataGrid1.CurrentRowIndex + 1)
End Sub
 
D

DraguVaso

Hm, thanks, but it doesn't really help. My DataGrid is ReadOnly = False, and
that changes a lot.
And it doesn't work for the KeyUp-event (ArrowDown-key)...
 
C

Cor

Hm, thanks, but it doesn't really help. My DataGrid is ReadOnly = False,
and
that changes a lot.
And it doesn't work for the KeyUp-event (ArrowDown-key)...

Did you try this and setting the datagrid to enable is true and readOnly to
false, I think that it is obvious that when the datagrid is disabled it
would not react on keystrokes (I hope that).

Cor
 
D

DraguVaso

My DataGrid is offcource enabled = true
and ReadOnly = False, because I have to be able to add values, hehe.

Basicly the problem is this: I'm not able to intercept the Arrow-Keys when
moving from Cell to Cell...
 

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