Forms :: Share Data Between Forms (as Opposed To Passing Data)

Nov 26, 2011

Quite a few threads on passing data from one form to another, but I'm struggling to work out how to share data between the two - back and forth.

For example:

Class1 is a class with 10 string properties

Form1 has 10 labels ("Label1", "Label2" etc) and a [Configure] button.
Form2 has 10 textboxes and a [Apply] button.

I want to load with Form1, and create an instance of Class1. Click the Configure button and load Form2, passing Class1. On Form2 I want to manually fill in the 10 textboxes and hit Apply. The Apply should update the Class1 instance and close the form.

Form1's Label controls should then be updated with the data from the Class1 instance.

I'm fine creating the forms and classes, as well as passing the class into Form2 with a custom Sub New(EmptyClass as Class1) constructor. This gets the empty class into Form2, but how can I get the populated class back to Form1?

As Form1 already exists I don't want to create a new instance with another custom Sub New(PopulatedClass as Class1)

It's also key to be able to use the Form2 multiple times, basically ending up with a Data class being displayed as part of Form1 but updated using Form2? (For example if the Class has already been created and populated with data when it's passed back to Form2 for the second time I would pre-load the Textboxes with the values already in the class).

View 3 Replies


ADVERTISEMENT

Passing Data Between Forms Without Any Public Methods Or Properties On The Forms

Dec 28, 2009

Passing data between forms without any public methods or properties on the forms. everything but the "Controller" class, which I would like you furnish. I just changed the title from "Intermediate" to "Beginner" This solution is an example of the Observer Pattern. The "Controller" class is the "observed" class, which in this case means it publishes events.

' File Definitions.vb

Public Delegate Sub MessageDelegate(ByVal sender As Object, ByVal e As MessageEventArgs)

Public Class MessageEventArgs : Inherits EventArgs
Public Message As String

[CODE]...

The program should initially display Form1, and Form2. Clicking of the button on either form will modify the Title Text of both forms. I think that you will find the final end result to be pretty neat, as it works with any number of open forms not just two. I think asking for the Controller class is easier than asking for the code in the forms. My solution for Controller class has 7 lines of content, 9 lines if you include Class, EndClass. A minimal solution could achieved with only 4 lines of content, but it would a textbook example of bad programming.

View 12 Replies

Forms :: Passing Data Between Forms?

Nov 12, 2009

I have a gridview on a form pulling user data. I have also created a basic login system where users login and their username/password is checked against a table in SQL Server 2005.The gridview is on Form 2 but i am having great difficulty in returning the records in the gridview for the user that is currently logged in.

View 3 Replies

Passing Data Between Forms

May 10, 2010

I have 2 forms. Using Visual Basic.On Form 1 there is a populated combo box. This was done so by running a query through it and populating it with PUZ_ID values from a data set.On form two there is a tool strip and below is a search query.I need to be able to select the value i want in the combo box on form 1, and launch a button that opens form 2, which has loaded the data that i binded onto the form.Anyone have any ideas/code or need me to clear this up a bit more?So i need to run something through a query, or make something public or what?

View 2 Replies

Passing Data Between Forms?

May 10, 2010

I have 2 forms. Using Visual Studio.

On Form 1 there is a populated combo box. This was done so by running a query through it and populating it with PUZ_ID values from a data set.

On form two there is a tool strip and below is a search query.

I need to be able to select the value i want in the combo box on form 1, and launch a button that opens form 2, which has loaded the data that i binded onto the form.

So i need to run something through a query, or make something public or what?

View 2 Replies

Passing Data Between Forms Vb 2008?

Oct 20, 2010

I need to pass a double from form1 to form2 and have form2 return this value back. My problem is while i can receive the proper value in form2 i can not seem to get the corrected value back in form1 (using byRef in form1). Here is the code snip

Dim AmountPaid As Double = 8
Dim newInvoiceRow As InvoiceDataSet.InvoiceRow
If (MakeAPayment.ShowDialog(AmountPaid) = Windows.Forms.DialogResult.OK) Then

View 4 Replies

Variables - Passing Data Between Forms?

Jan 24, 2011

I have a form that has a button, when clicked it pops up a Dialog Form. Within this dialog form the user needs to select some data and when the user is finished they click the OK button. Once they click the OK button it needs to return an integer back to the previous form.I created a Dialog Form and tried calling it via the code below:

Dim intResult as Integer = frmData.ShowDialog()
Debug.Writeline(intResult)

However, it seems I can only return DialogResults (Abort, Cancel, Ignore...)I was wondering how I can try this without having to create a public variable and storing the result there.

View 3 Replies

VS 2008 Passing Data Between Forms?

Jul 8, 2010

Form1 is a Datagridview which is non editable. I want a user to be able to double click and open Form2, which will allow editing BUTForm2 is a list view and also had a binding navigator so I guess I cannot use dialogue? I do not want to simply just edit in a dialogue and save.Is there an easy way to get the record from Form1 and pass it to the controls in Form2 so that the correct record is displayed?

View 5 Replies

[2008] Passing Data Between 2 Forms?

Jun 18, 2009

I am trying to pass data between forms on a double click operation. On Form1, I have a simple database with three fields (ProfileID(PK), Profile First, Profile Surname). The database has 10 records at present which displays all records in a datagrid view which is set to read only. I have the Selection Mode set to FullRowSelect to highlight the full row.Form2, is a form to Display one record at a time. This form allows editing and saving of changes.How would I go about coding in vb.net to firstly get the ProfileID from the relevant row and send this into Form2 to display that record for editing?

View 10 Replies

VS 2008 - Sending Data / Passing Value Between Forms

Dec 15, 2009

Imagine a project with couple of forms and a module. Now as per my knowledge if i want to send some data from one form to another then :

- If I declare variable friend/public in a module then it can be accessed in the entire project (thus also between forms).
- If I just have to send data from one form to another, then I can call the other form's sub/function and pass value.
- If the pass value by reference then I can get new value only if its changed in that function.

Now what the issue is, I need to pass a variable to a form and in that form when user types contents in a textbox or makes other selection and presses OK button then it should return some values back to the calling form. Now how can I achieve this (without declaring global variables which will be accessible everywhere) ?

View 14 Replies

Passing Values Between Forms And Presenting Sql Data In Datagrid View

Jun 10, 2011

I have two forms and I am running a sql query to provide a set of variables in my first form that I need to pass to my second form. Here is the code that I have:[code]to form 2 which then shows the data retrieved from a sql query in the load event to a datagrid view.

View 19 Replies

Create A Data Forms With Forms Wizard In VB 2005?

Jan 21, 2010

How to create a data forms with the data forms wizard in VB 2005

View 6 Replies

Forms :: Retaining Data Across Multiple Forms

Sep 8, 2010

VB.NET newbie here... I have an vb.net windows application set up. It has multiple forms, about 6 in all. There's a main menu form, and then 5 other forms to collect data. The user will collect data on each form and bounce back and forth between forms. How do I get the forms to retain the data that has been entered into the text boxes and/or other controls on the forms? For example, they might fill out a few textboxes on a form, but then need to go to a different form and fill something out... and then back to the previous form. Right now, when they come back to the form, all the data previously entered in to the text boxes is gone.

View 1 Replies

Forms :: Passing Several Textbox.text Between Forms

Jul 28, 2010

I use the code

Dim Selvk As New Selvkost2
Selvk.PassedText = TextBox29.Text
Selvk.Show()

[code]....

in my second form and the text passes. but I need to pass values from 20 textboxes. do I have to copy the code in my second form 20 times an declare passedtext2 and so on or is there an easier way to do this?

View 3 Replies

Forms :: Wonky Variable Passing In Forms

Apr 22, 2010

This is my first Windows app to create since VB6. I've been in the world of ASP and ASP.NET for many years. However, now I have been asked to create a simple app that needs to be windows based.

[Code]...

View 4 Replies

Input Several Boxes Of Data On One Form And Display Individual Pieces Of That Data On Several Other Forms

May 22, 2009

I have just started with vb and would like to know if there is a way to input several boxes of data on one form and display individual pieces of that data on several other forms at timed events in the future?

View 1 Replies

Forms :: Display Data In Grid View Using Code That Can Edit, Update And Delete The Data?

Oct 6, 2011

how to display data in grid view using code that you can edit, update and delete the data...do i need to have a stored proc in this?

View 4 Replies

Forms :: Populate A Data Table With Some Data From Text File

Mar 29, 2010

Here is the code that I already have:

[Code]...

View 4 Replies

INSERTING - Accepting Both The Forms Data And The TabControl Data

Jul 22, 2010

I am INSERTING into 2 different tables with 2 different buttons (One after the other by clicking each button). I have a form with 1 button directly on it to INSERT into tblCustomers from a field that is directly on the form as well. I then have a TabControl with another button with other fields (5 to be exact).

After I add data to the data base by filling out the field on the form and then by first clicking the add button located directly on the form and then add data to the fields directly on the TabControl the data will not INSERT itself into the tables in the data base for the 2nd table. Only the first table get data in it and not the one related to the TabControl.

BUT if i add data in the TabControl and then click the button on the TabControl it adds data into to the 2nd table. Is there a way to refresh my program so that it will accept both the "forms data" and the "TabControl data"?

View 3 Replies

Forms :: MDI Forms And Passing Information

Dec 17, 2010

Example Form1 with data bound controls and a Public Variable Form1Var.Form2 with data bound controls and a Public Variable Form2Var DataTables are related Form2 Data is related to Form1 Data in a one-to-many.What I am trying to accomplish.When editing Form1 data there is a button to open Form2 if new data needs to be added. on closing Form2 I would like Form1 to remain at the state it was in before opening Form2. If I Change Visibility of Form1 when Form2 is opened upon Retun to Form1 Data is reloaded, if I minimise Form1 when Form2 is opened upon return to Form1 Public variables are reset to defaults.I have many Forms with many controls and buttons to do Lookups or additional add to related tables.

View 2 Replies

Forms :: Passing Information Between Forms

Aug 21, 2011

I'm getting a little fustrated, ive been trying to figure out how to allow my main from access to a sub form. what I'm initially aiming for is control of text and font color via a dialog on the main form and the results to appear on the second form, if that makes sense. Most of my knowlege resides around using VB.net for creating games and not progams. ill post the code so you guys might be able to get a better understanding of what im looking for as a result.

[Code]...

View 2 Replies

Forms :: Passing Values Between Forms

Jul 23, 2009

My scenerio is a form with a button, when clicked opens a form dialog. The dialog allows the user to enter a text box. I want to read the value of the text box from the main form into a variable to be used with an SQL statement. The following code is used to create a new instance of the form dialog if one does not exist:-

[Code]...

View 2 Replies

Forms :: Passing Variables Between Forms

Nov 27, 2009

I seem to be running into an issue. This may seem like a noob question (which it really is, I only have experience in vb6 from years ago) but what Im trying to do is pass a variable from one form to another. Ive tried telling the first form to set the value of the variable on the second form like so frmsecond.variable = "value" but that does not work. Ive tried placing a public variable in a module to do it, but again, no luck. The only way seem to be able to get it to work is the second form setting the variable by reading the value from the first form like so [code]The problem I have with that code is what if for some reason the selected line gets changed as the form is loading or something to that nature. It doesnt seem very secure.

View 5 Replies

Forms - Copy Data Between Data Grids?

Mar 7, 2012

i'm trying to pass a variable between two datagrids. The first is on an main form, and the second is in a dialog form.

I tried using functions and also through public variables like this:
Invoice_new (Parent FORM):

Controls:

DatagridView: invoice_items
Public WriteOnly Property ValueFromChild() As String
Set(ByVal Value As String)

[Code]....

View 1 Replies

Getting System.Data.DataRowView In Drop Down List As Opposed To Values From Database

Sep 30, 2010

I'm populating a custom dropdown list control on the fly that's tied to data grid using VB .NET 2008. The form will display all the manufactures when the edit button on the data grid is selected.

The dropdown I created works fine. However, when I try to populate the drop down with the respected manufacture values from the database, I only get a value of "System.Data.DataRowView" that being populated in the dropdown list as opposed to my values from the database.

Here's the basic code I use to first create and populate the drop down control:

<asp:DropDownList ID="Manufacturedd" Runat="server" DataSource='<%# m_ItrackerData.Tables("Misc_Manufacture") %>' SelectedIndex='<%# getSelectedManufacture(DataBinder.Eval(Container, "DataItem.Manufacture"))
%>'></asp:DropDownList>

[Code]....

View 1 Replies

How To Share DataSet Among Two Forms

Jan 13, 2009

I'm new to VB2008 and SQL Server. I have two forms (frmCustomer and frmDetail). The frmCustomer has a datagridview containing general data of customers, and a button to open frmDetail, which contains each customers detail information. All data modification is done on frmDetail (add, delete, and edit). Currently, both forms are binded to the dataset (same table). When the two forms are loaded, each form performs a FILL function that retrieves the data from SQL Server. In addition, all modifications done on frmDetail does not show up on frmCustomer until I perform the FILL function again on both forms. Seems like I'm maintaining 2 sets of data from the same table, and I think I'm doing more work than I have to. I'm sure there are ways to make this easier, such as bind both forms to a single dataset, so I don't have to do everything twice.

View 1 Replies

How To Share Variables Between Forms

Feb 17, 2012

Is it possible to share subscripted variables and their data between forms? So far I can't see the variables I made public in one form, in a second form.

View 5 Replies

Share Forms Between Projects?

Dec 19, 2009

I've recently noticed that a solution can contain multiple projects. I'd like to know if I can create a form that exists in multiple projects, so i can edit one form (or class) instead of six, and have it published in each one of them separately? I hope that makes sense....I seek not answers, but understanding, that I may not solve, but learn.
What good is a fish without the skill to catch it?

View 4 Replies

Share Variables With Other Forms?

Mar 6, 2010

Say I have public string variable called "_Test" on Form1, how can I allow Form2 to edit/read the variable from that form? I tried putting this on Form2:

Public _Test as String = Form1._Test

But if I start Form2 without Form1 being open, it gives me an exception.

View 4 Replies

Share A String With Multiple Forms?

Apr 13, 2009

I need to share strings (array) with more then one form.

View 3 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved