Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
405
Can't activate cell in code?!
posted

Ok Mike, I have another one for you...

I'm trying to activate a cell in code.  I'm using the following line:

 

    Private Sub UltraGrid1_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles UltraGrid1.KeyDown
            Dim row As Infragistics.Win.UltraWinGrid.UltraGridRow = UltraGrid1.ActiveRow
            Dim cel As Infragistics.Win.UltraWinGrid.UltraGridCell = UltraGrid1.ActiveCell

            If e.KeyCode = Keys.Tab Then
                If cel IsNot Nothing AndAlso cel.Column.Key = "PctDn" Then
                    If row.HasNextSibling Then
                        row.GetSibling(Infragistics.Win.UltraWinGrid.SiblingRow.Next).Cells("AdjustedValueDisplay").Activate()
          Else
                        row.GetSibling(Infragistics.Win.UltraWinGrid.SiblingRow.First).Cells("AdjustedValueDisplay").Activate()
                    End If
                End If
            End If
        End Sub

What I'm trying to do is make it so if they tab on the last cell of the row ("PctDn") that it'll jump to the 3rd cell in the next row ("AdjustedValueDisplay").  Instead, however, it jumps to the cell following the cell I am specifying.  I can hack this by just naming the preceding column, but that's just that... a hack.  I would like to know the proper way to do this.  I have a feeling I need to cancel an event somewhere, as it's obviously going to the cell I specify, but then automatically being thrown to the next row, and I have no code that would do that.

Any thoughts?

Thanks!

Rocky

Parents
  • 69832
    Offline posted

    What is probably happening is, the default key action for tab key is being performed along with the code you have in the KeyDown event, since you aren't setting the Handled property of the event arguments to true. If you do that, the grid will forego the action mapped for that key, thus preventing the 'NextCellByTab' action from being performed. Another solution to the problem is to remove that mapping from the KeyActionMappings collection.

Reply Children
No Data