Results 1 to 11 of 11

Thread: moving through textboxes by arrows

  1. #1

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083

    moving through textboxes by arrows

    hi
    how can I move through textboxes using down and up arrows ?
    thanx

  2. #2

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    anyone ?

  3. #3

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    OK , What is the ascii code of vbKeyDown then ?

  4. #4
    Registered User
    Join Date
    Nov 2002
    Location
    Växjö, Sweden
    Posts
    314
    Didn't try this but..... its from the KeyUp event args...

    Code:
    If e.KeyCode = Keys.Up Then

  5. #5

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    no way . aren't all arrow keys have events ? I mean when I press left arrow then something would happen .anyone can help plz ?

  6. #6
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    This is how I do it with C#
    Code:
    private void textBox1_KeyUp(object sender, System.Windows.Forms.KeyEventArgs e)
    {
    	if(e.KeyCode.ToString() == "Down")
    	{
    		// Go to the control down from this one.
    		textBox2.Focus();
    		return;
    	}
    	if(e.KeyCode.ToString() == "Up")
    	{
    		// Go to the control up from this one.
    		someControlOnTop.Focus();
    		return;
    	}
    }

  7. #7

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    exactly what I needed . Thanks hellswraith.

  8. #8
    Registered User
    Join Date
    Nov 2002
    Location
    Växjö, Sweden
    Posts
    314
    Just out of curiousity, why do you have to use tostring?

    apparently 'If e.KeyCode = Keys.Up Then' didn't work according to Pirate but 'If e.KeyCode.ToString = "Up" Then' did?

    I have still not tried this, but this puzzles me.....

  9. #9

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    your way it perfect too Athley. When I was trying that in the KeyPress not in the KeyUp . I am using this anyways:
    VB Code:
    1. Private Sub TextBox1_KeyUp........................
    2. If e.KeyCode = Keys.Up Then
    3.             TextBox2.Focus()
    4.         End If
    5.         If e.KeyCode = Keys.Down Then
    6.             TextBox3.Focus()
    7.         End If
    8. end sub
    I think no need to convert that to string Unless C# only accepts that way , I guess no .

  10. #10
    Registered User
    Join Date
    Nov 2002
    Location
    Växjö, Sweden
    Posts
    314
    Aha, well I got a little confused there. Now I can sleep tonight.

  11. #11

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    hehe

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width