Using Arrow buttons instead of Tab to toggle between Textboxes

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • adarshyam
    New Member
    • Oct 2008
    • 31

    Using Arrow buttons instead of Tab to toggle between Textboxes

    Hi..
    I wanna use down arrow and up arrow to move between TextBoxes(that are Dynamically created) instead of the default Tab key.. Please help me if u ve any idea.. Thanks
  • Curtis Rutland
    Recognized Expert Specialist
    • Apr 2008
    • 3264

    #2
    You will have to handle the KeyDown event for each textbox, and check to see if the keys are one of the arrow keys, and then .Focus() on the appropriate textbox.

    Comment

    • adarshyam
      New Member
      • Oct 2008
      • 31

      #3
      but its dynamically created.. how can i make changes in tat.

      here s the code.. pls help me figure out

      Code:
      Public Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
      
      If IsPostBack Then
      
      Try
      
      If Not TextBox1.Text Is String.Empty Then
      
      numofper = TextBox1.Text
      
      ReDim TxtDyn1(numofper)
      
      ReDim TxtDyn2(numofper)
      
      ReDim TxtDyn3(numofper)
      
      ReDim TxtDyn4(numofper)
      
      Else
      
      MsgBox(
      "Enter the Number of Periods")
      
      End If

      'To create the dynamic text box and add the controls to panel, save them in session state

      Code:
      For i As Integer = 0 To numofper - 1
      
      TxtDyn1(i) =New TextBox
      
      TxtDyn1(i).EnableViewState =True
      
      Panel1.Controls.Add(TxtDyn1(i))
      
      textdynamic1.Add(textdynamic1)
      
      Next
      .
      .
      .

      Comment

      • tlhintoq
        Recognized Expert Specialist
        • Mar 2008
        • 3532

        #4
        The [TAB] key uses an index on the form. You can set the order of movement by setting the Tab Index.

        For your want you will have to write a method that scans through all of the controls on your form, get the .Location of each control, then determine which control is "down" from the control that currently has focus.

        You'll have to decide which is more important: If a control exists that is lower in location, but far to the left - of a different control that is maybe 2 pixels lower, but not as many pixels away horizontally.

        Comment

        • adarshyam
          New Member
          • Oct 2008
          • 31

          #5
          thank you very much..

          Comment

          Working...