How to use Arrow keys similarly like tab in C#,Windows forms

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • neehakale
    New Member
    • Aug 2007
    • 46

    How to use Arrow keys similarly like tab in C#,Windows forms

    language using: C#.

    platform for program: WINDOWS FORM

    I have to use arrow keys tro move from one text box to other ,Same as tab..

    Is there any way to do this???
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    Look at the key events for the textbox (key press, keyup, keydown, etc) and handle shuffling focus accordingly

    Comment

    • abev
      New Member
      • Jan 2008
      • 22

      #3
      Originally posted by neehakale
      language using: C#.

      platform for program: WINDOWS FORM

      I have to use arrow keys tro move from one text box to other ,Same as tab..

      Is there any way to do this???
      neehakale this is what I use in vb.net. This is for the down key, but you could set it up for any key or multiple key presses. Maybe you could convert it to C# with the vb.net to c# converter?

      Code:
              
      If e.KeyCode = Keys.Down Then
                  Dim cur_cell As DataGridViewCell = _
                          InsertionOrderDetailDataGridView.CurrentCell
                  Dim col As Integer = cur_cell.ColumnIndex
                  col = (col + 1) Mod InsertionOrderDetailDataGridView.Columns.Count
                  cur_cell = InsertionOrderDetailDataGridView.CurrentRow.Cells(col)
                  InsertionOrderDetailDataGridView.CurrentCell = cur_cell
      
                  e.Handled = True
              End If
      This is in the keydown event of the gridview.

      Comment

      Working...