CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2010
    Posts
    10

    [RESOLVED] Open a 2nd form from menu and when closing it placeing the contents in a combo box

    Hi, can a user open a second form from the menu? I know how to use the menu editor to open files, and add commands but i don't know how ( and couldn't find) the code for opening a second form, is this possible?
    If it is can i then send some contents from a textbox(from form 2) to a combo box that is located in form 1?

    thanks in advance for taking the time to read and maybe answer my question

  2. #2
    Join Date
    Apr 2009
    Posts
    394

    Re: Open a 2nd form from menu and when closing it placeing the contents in a combo bo

    Yes it is... One way...
    Code:
    Form2.Show
    But this will do nothing for you on retrieving values from Form2 and this code will allow the user to interact with both forms at the same time so more than likely you will want to show form2 with the vbmodal constant...
    Code:
    Form2.Show vbModal, Me
    This will allow the user only to be able to interact with form2 until it is closed/or hidden. So, instead of putting a unload me in the click event of the command button that will make form2 go away, use me.hide and then in form1 you will be able to pull the value from the text box with something like...
    Code:
    MyVariable = Form2.Text1.Text
    Combo1.AddItem MyVariable
    After that, you can put the unload form2 code in... So, your entire code in form1 would look like...
    Code:
    Form2.Show vbModal, Me
    MyVariable = Form2.Text1.Text
    Combo1.AddItem MyVariable
    Unload Form2
    Now, that is only one way in which to achieve what you want...



    Good Luck

  3. #3
    Join Date
    Jul 2006
    Location
    Germany
    Posts
    3,725

    Re: Open a 2nd form from menu and when closing it placeing the contents in a combo bo

    Right. And in fact you don't even have to use a variable inbetween since you can directly add to the combo box:
    Code:
    Combo1.AddItem Form2.Text1.Text
    Combo1.AddItem Form2.Text2.Text
    ...

  4. #4
    Join Date
    Mar 2010
    Posts
    10

    Re: Open a 2nd form from menu and when closing it placeing the contents in a combo bo

    thanks a lot for the answers

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

Featured