insert differnt forms in a single form under different tabs? and a textBox question

This is a discussion on insert differnt forms in a single form under different tabs? and a textBox question within the C# Programming forums, part of the General Programming Boards category; Hi. I have 2 questions: 1- I have 2 textBoxes which any of them should get just 2 characters. When ...

  1. #1
    Registered User
    Join Date
    Nov 2003
    Posts
    177

    insert differnt forms in a single form under different tabs? and a textBox question

    Hi.
    I have 2 questions:
    1-
    I have 2 textBoxes which any of them should get just 2 characters.
    When the user starts entering data in the first textBox, I want the cursor jump to the second textBox right after the second character entered.
    And in the second textBox, I want the cursor jump to the next item in the form.
    How can I do that?
    2-
    The program I'm writing contains 6 parts.
    My problem is that the forms of these 6 parts are different and actually I have form1, form2,....,form6.
    The size of these forms are the same.
    How can I insert all of them in a single form under 6 different tabs?
    I mean:
    Form1 is the default form and when the user clicks on the second tab, form2 appears and so on.
    Something similar to Microsoft word(2007) tabs which under different tabs (home, insert, Page layout,....) we see different forms.

    Thank you

  2. #2
    Cat
    Cat is offline
    Registered User
    Join Date
    May 2003
    Posts
    1,571
    Quote Originally Posted by arian View Post
    Hi.
    I have 2 questions:
    1-
    I have 2 textBoxes which any of them should get just 2 characters.
    When the user starts entering data in the first textBox, I want the cursor jump to the second textBox right after the second character entered.
    And in the second textBox, I want the cursor jump to the next item in the form.
    How can I do that?
    Firstly, set the textbox's MaxLength parameter to 2, so you don't ever get more than you want (e.g. if someone copy-pastes, it will only put 2 characters in still)

    Secondly, under the textbox events, make an event handler for TextChanged: if textBox1.Text.Length == 2, then you can do textBox2.Focus()

    2-
    The program I'm writing contains 6 parts.
    My problem is that the forms of these 6 parts are different and actually I have form1, form2,....,form6.
    The size of these forms are the same.
    How can I insert all of them in a single form under 6 different tabs?
    I mean:
    Form1 is the default form and when the user clicks on the second tab, form2 appears and so on.
    Something similar to Microsoft word(2007) tabs which under different tabs (home, insert, Page layout,....) we see different forms.
    Thank you
    Personally, I would refactor each of the forms to be a user control instead of a form. This should be mainly just a copy-and-paste job as they're very similar. The only real difference is that forms are designed to be shown directly, while user controls are designed to be added to a form. For what you're doing, a user control would be the better choice.

    Then, make only one form, with a TabControl on it. Make 6 tabs, and inside each tab put your custom control (docked to the inside of the tab control, so it will resize with the tab control itself)
    Last edited by Cat; 04-01-2009 at 10:56 AM.
    You ever try a pink golf ball, Wally? Why, the wind shear on a pink ball alone can take the head clean off a 90 pound midget at 300 yards.

  3. #3
    Registered User
    Join Date
    Nov 2003
    Posts
    177
    sorry for my delay and thankkkkkkkkkkkkk you

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21