Ask Me Help Desk

Ask Me Help Desk (https://www.askmehelpdesk.com/forum.php)
-   Visual Basic (https://www.askmehelpdesk.com/forumdisplay.php?f=469)
-   -   Ineritence? Include? (https://www.askmehelpdesk.com/showthread.php?t=337068)

  • Apr 2, 2009, 11:29 AM
    albear
    Ineritence? Include?
    In visual studio 05 I'm using visual basic and on one form (form1) I have a listbox called Pnames and on a different form (form2) I have a textbox where the user inputs their name, on that same form I have a button that when clicked I want the name in the textbox to be added to the list box in form1

    I've been looking for ways to solve this on the internet but when I tried it messed form2 up and I had to redo it again, any help would be greatly appreciated
    Thanks :)
  • Apr 2, 2009, 07:31 PM
    Perito

    Is the name of the listbox known before you compile? I presume it is, but if not, you'll have to use "reflection" to solve the problem.

    If both forms have been created (you have instances to both forms), you can make the textbox Public on the Form1 listbox and access it directly from Form2. I don't like that approach, so I always create a Public Property on Form1. I then use that property from Form2 to pass the value that I want.

    You'll have to pass a Form1 reference to Form2 when it is created. I suggest you use a Public Property to pass that reference also.

    If you need examples, I can probably generate them for you.

  • All times are GMT -7. The time now is 02:02 AM.