473,385 Members | 1,942 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

getting a string from a child form to a parent form

it0ny
4
Hi guys,

I am fairly new to visualbasic. A little background from me, I've programmed before in C++, Java, and PHP so I know programming. But I am new when it comes to GUI development too.

My question is that I have a main form and I've created another small form.
In the main form I show the small form when they click a button, like this:

Expand|Select|Wrap|Line Numbers
  1. Private Sub AddButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
  2.   Handles AddButton.Click
  3.         Dim License As LicenseNewForm = New LicenseNewForm
  4.         License.ShowDialog()
  5. End Sub
  6.  
then the LicenseNewForm appears. The problem the I stumble upon is how I get the information from the license form to the main form when they click a button in the license form or close the license form.

The information is more then just a simple input, so I can't use a InputBox call
because the license form has 3 comboboxes and a textbox to get the input from the user and then I need to send that input to the main form.

I don't even know if it is possible, so I thought of asking about it here.

Thanks for the help in advance.
Feb 27 '09 #1
7 2100
debasisdas
8,127 Expert 4TB
question moved to .net forum
Mar 1 '09 #2
tlhintoq
3,525 Expert 2GB
Don't think of it as 'sending' the info to the main form.
When the child form closes, don't dispose of it.
It will still exist in memory until it goes out of scope.
So you display it using the ShowDialog() method. This causes execution to remain on the child dialog until you click the 'ok' button (or whatever button has the DialogResult property of 'accept', to be more accurate).

From there your main form can just ask the child form what are the values of its controls or variable or properties.

I went from C++ to C#, so I can't really give you VB code to accomplish it. I know there is a couple other questions very similar to this one in the last couple weeks under the C# forum that have some code samples if you want to browse back a week or two for questions with nearly the same title as this one.
Mar 1 '09 #3
it0ny
4
@debasisdas
thanks, newbie mistake :P

@tlhintoq
thanks for the reply. So I can use the form object as an open thread and get the info. That gave me an idea. Thanks.
Mar 1 '09 #4
tlhintoq
3,525 Expert 2GB
A 'thread' is a totally different thing. Start now with keeping terms and mental images straight. It will keep you from having to 'unlearn' bad habits later.

The child form is an object that you can reference until it goes out of scope.

If you created the child form from inside a method, then its scope is the lifespan of the creating method. If you create the child form as a 'global' or member object at the creation of your application, then it's lifespan is that of the application. I do some simple tool and control palettes this way.
Mar 1 '09 #5
OuTCasT
374 256MB
@it0ny
You can add a module to your project and use public strings to hold information until the application is closed or values are reset.
Or when working with child forms you can call the information using the mdiParents name and then the control on the form.
Mar 2 '09 #6
kunal pawar
297 100+
I guess you want to send information from Child Form to Main form.

Then create publue properties for Main form.

and set values from Child form.

I think this will helps you
Mar 2 '09 #7
it0ny
4
thanks OuTCasT and kunal pawar.

I tried to do it by changing the public variables in the main form, but it didn't work. I couldn't find why.
So I am using a module now. Thanks for the quick reply guys. you saved my butt.
Mar 3 '09 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

13
by: Stuart McGraw | last post by:
I haven't been able to figure this out and would appreciate some help... I have two tables, both with autonumber primary keys, and linked in a conventional master-child relationship. I've...
8
by: CJack | last post by:
hy, I have an mdi application, i create a child form and I want to know when a button is pressed while that child form is loaded. I have this code: private void frmTestBaby_KeyUp(object sender,...
3
by: Maheshkumar.R | last post by:
Hi groups, How i can command over the MDI CHIlD forms created dynamically at runtime from PARENT. Let say, i have generated 5 mdichild forms, but i want to work with child form1 from MDI...
16
by: John | last post by:
Hi I have posted this question several times but have received no reply. I have a main form which contains a panel which in turn contains a child form, like this; MainForm->MyPanel->ChildForm....
10
by: Charles Law | last post by:
For some reason, when I click the X to close my MDI parent form, the action appears to be re-directed to one of the MDI child forms, and the parent remains open. I am then unable to close the...
3
by: Zack Sessions | last post by:
I am using VB.NET 2003. I have read the threads concerning the problem where the FormStartPosition of CenterParent is ignored if the form is displayed with the Show method as opposed to the...
4
by: LCAdeveloper | last post by:
Help! Another newbie question I'm afraid. I have a toolbar on an MDI form, which I can control OK to produce a child form. When the child form is active, the appropriate MDI parent form toolbar...
4
by: eBob.com | last post by:
I have a "parent" form (if that's the right terminology), Form1. I declare two public values in the parent form : Public Class Form1 Inherits System.Windows.Forms.Form Public CurDir As String =...
4
by: Richard Lewis Haggard | last post by:
What is the mechanism by which a child window can notify its parent that it has been clicked on? -- Richard Lewis Haggard www.Haggard-And-Associates.com
3
by: O.B. | last post by:
I have a form that shows another child form using the Show() operation. Since the child is modaless, I would like the option that when I click anywhere on the parent form that the parent form...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.