C# - Copy A Textbox Value From Form1 To Form2?

Aug 2, 2010

I have Form1 that has a textbox and a button. When user clicks the button in Form1, Form2 opens up with a label control that carries the value of textbox in Form1.

What i did is set the textbox modifier of Form1 to Public, but when i call the textbox name of Form1 in Form2, i get an error that says "The name "txtbx1" doesn't exist in the current context". I wonder why since i already set the modifier of txtbx1 to Public.

Quick Note: i tried to instantiate Form1 in Form2 as:

Form1 f1 = new Form1();

and then call

f1.txtbx1.text

The odd thing is Form1 could not be instantiated (not highlighting occurs). On the other hand if i do Form2 f2 = new Form2(); Form2 gets highlighted!

This is how i show Form2 from Form1:

SetSalary salForm = new SetSalary();
salForm.ShowDialog();

Note that SetSalary represents Form2.

View 5 Replies


ADVERTISEMENT

Possible To Copy Form2 Three Times On Form1 With Different Variables In Text Boxes?

Oct 18, 2009

I recently bought a barcode scanner for God knows what reason, just to play around and now it seems that its easy to sort out everything at house with it (e.g. Disc Collection). So I decided that I need a special program for it to get sorted with the collection. I am new to Visual Basic, but used to do programs with Java 6 years ago, but it doesn't seem to be any similar to each other. Basically I have a Microsoft Visual Basic 2008 and here is what I want to do:I have Form1 which contains of a textbox and a button (which will be Enter further), a textbox for total amount spent (which has to be calculated from Form2 and a nice background. I also have a Form2 in the same project, which contains 3 textboxes (Title, Price and the barcode numbers)So my problems are: As I said there are just 3 textboxes in Form2. Is it possible to copy Form2 three times on Form1 with different variables in text boxes? For example Form2 1st copy will have one Title in textbox, Form2 2nd copy will have another Title in textbox and etc. The Titles are in excel (.xls) file.That is a problem further, but my problem for now is how to make barcode scanner working. The barcode scanner basically reads barcode and inputs numbers in a textfield and automatically presses enter.As I am new, I do not know how to make this work. When I launch the program the textbox has to be selected rightaway, so that I do not have to use mouse. As it is selected I read the barcode and the numbers are in the textbox right away and Enter key is pressed (but I did not assign OK button with a Enter key and I cannot output anything now). So how do I assign the button with Enter key and the textbox? Now as the button is pressed (OR ENTER KEY is pressed) The text in the textbox has to be selected again (so that I can input a new barcode) and Form2 has to be called on a certain place of the screen (e.g. 200x100px is the starting location).

Now when the Form2 was called it read the data from Excel spreadsheet and now the textfield in Form1 is ready to input new barcode. As new barcode was read the same situation is happening, but now the Form2 is copied into a new place with new parameters (e.g. 300x100px is the starting point).Same for the third time, but on 400x100px.For the fourth time the Form2 is not copied again. However the parameters of the third copy are getting the new data. Parameters of the third one are going to the second copy, second copy to the first one and the first one is stored in a text file or somewhere else to use further. (I wanted to use up and down buttons to search for what I have scanned)

View 2 Replies

Get Textbox Value Of Form1 To Sql Query Of Form2?

Mar 7, 2011

[Code]....

i'm using this code but the grp n dept values are not coming from form1...

View 2 Replies

VS 2008 Textbox From Form1 Put Into Web Browser On Form2?

Oct 4, 2009

Ok I have 2 text box on form 1...

Username:

TEXTBOX HERE

Password:

TEXTBOX HERE

The web browser is on form 2...

When I click login, how can I make the username text box text and the password text box text inject into the web browsers username and password text box's on the web browser ON THE OTHER FORM?

View 1 Replies

Textbox In Form1 Dictates Amount Of Textboxes In Form2?

Feb 3, 2010

I am using VB 2008 Express Edition. I made a little 3 form program to keep track of score while playing Gin. Now I'd like to make another score sheet application for a different card game with more people.I would like Form1 to have a textbox which the user may put a number in. Then on a button click that would take me to Form2 which would have the same amount of textboxes (name of player) as the user indicated on the first form.Eventually I'd like to build a UserControl (which would house the scoring for one player) and have Form3 populate with the same amount of UserControls as Form1.textbox indicates.

View 2 Replies

Update Form2 Table1DataGridView First Name Using Form1 Textbox.text?

Sep 17, 2010

how can i update Form2 Table1DataGridView firstname using Form1 Textbox.text?

View 5 Replies

Pass Data From Form2 To Form1 When Form2 Is Closing

Nov 29, 2009

Last one day I could not manage to pass data from one form2 other form.

When I am opening Form2 from Form1, I can pass data from Form1 to Form2.

When I am closing Form2, I want to pass data from Form2 to Form1 which is still open when I close form2.

I try to use shared textbox, but I understand that this is nt supported.

View 11 Replies

Forms :: Form Variable Value Blank / Null When Move From Form1 To Form2 And Back To Form1

Oct 27, 2009

In my window application, Form1 variable eg. Public str as string. value blank/null when move to Form2 and Back to Form1. How to maintain Form1 varable's value when back to Form1 In vb.net if any one know, reply me soon

View 2 Replies

Forms :: Navigate From Form1 To Form2. And Then Close Form1?

Feb 16, 2009

I have got 2 forms ----- form1 and form2

i wanted to navigate from form1 to form2. and then close form1

i did the following code.

-sub form1 _ page load
dim form as new form2
form.show()
me.close
-end sub

i also tried -- form1.close() and form1.dispose() but all in vain

Problem is that my form1 is not getting closed

View 7 Replies

Call Menu From Form2 To Form1 Like VB 6 Do "Me.PopupMenu Form2.mymenu"?

Dec 15, 2009

I have 2 forms. On form1 i have listview on form2 i have menu. I'd like to call form2 menu from Form1 ListView1_MouseUp. I tryed to use this code

[Code]...

View 3 Replies

Call Form2 From Form1 In Wpf

Sep 18, 2011

if in vb.net, I can call like this form2.show (), but how in wpf vb.net?

View 1 Replies

Changing Form1 From Form2

Oct 22, 2008

I am having problems making changes to form1 from form2..I tried declaring form1 on form2 Dim f1 as form1.[code]I can change form2 from form1 but not the reverse.

View 5 Replies

Form1 Related To Form2?

Nov 21, 2011

this looks like to the forum I need. I have a question on somethings. My data is pulled from a local SQL sever express. First, Form1(Customer) has has data. his customer has a vehicle in another form this form is called (Vehicle) form.I have created the customer form in a detailed form and the vehicle form on a grid design.

View 1 Replies

Form1 To Open Form2?

Mar 27, 2009

I have been converting my VB6 programmes to VB 2008, and I am beginning to regret it.According to the books that I am reading on the subject, I can call a second form from the first one. That is, when the first form code has completed, and the final line reads:

frmForm2.Show()

the second form should open and wait for input.This does not happen, the form flashes and then disappears without allowing any input, or button click.I must admit that I preferred being able to start from a module, with a Main() sub, which then read the forms, a la VB6. everything seemed to work fine then.

View 16 Replies

Form2.show End Up Behind Form1?

Apr 1, 2012

I made 2 form.

In form1 I have this:

form2.show()
form2 ends up behind form1, how can I make form2 appear in front of form1?

Form2.showdialog() will make form1 disappear until form2 is closed, that is not what I want.

View 11 Replies

IDE :: Transfer Form1 Val To Form2 ?

Jun 29, 2009

There is no session in desktop app in vb.net .i want to transfer valuse from one form to other want to transfer form 1 (TextBox1.Text) value on form2 (objuserpage.Label1.Text)

'form 1=userpage.vb
Dim objuserpage As New userpage()
' form 1 textbox TextBox1.Text[code].....

View 2 Replies

Panel To Form2 On Form1?

Mar 25, 2011

I have a panel to form2 on my form1 which displays a picture box fine. I got a peice of code that stores 5 images in an image list and works off a keypress.

When I press the Comma key the image changes to the next one. This works fine on its own but when I put it in form2 and try to put the keypress code on form1 for it to change image in the panel it doesn't work.

View 4 Replies

Set A Picture From Form1 To Form2?

Mar 11, 2010

I would like to do 2 things (or one of the two)

first, I have in form1 a textbox1 and i would like to bring the info of it to a textbox (or label) in form2

second, If it's possible i would like to set a picture from form1 to form2 (if that's possible)

View 2 Replies

Set Value Of Datagridview In FORM2 From Value In FORM1?

Jun 11, 2011

In the FORM1, the datagridview contain some product column and user can input the number of product quantities they want to buy.if user press the "buy" button, i want it to open FORM2, with datagridview containing the list of the product they buy from datagridview in FORM1.[code]...

View 1 Replies

Using Variables From Form1.vb To Form2.vb?

Apr 29, 2010

I have an equation on Form1.vb that calculates a number. I need that number to be used in another separate formula that's on Form2.vb. How do I do this? I thought using a Module would work but I can't get the function on the Module to "see" the formula and/or variables that I need on Form1.vb. I am using VB 2005.

View 8 Replies

.net Login In Form1 Then Form2 Will Welcome The User?

Apr 15, 2012

i have here a login in form1 that is connected to my sql database.i want that if i login in form1. the form2 will show my name.

View 11 Replies

Accessing Listview1 In Form1 From Form2?

May 22, 2009

I need to have access to the Listview1 in form1 from form2, something like this:

Form1.Listview1.Items....

View 19 Replies

Calling Data From Form1 Into Form2?

May 6, 2009

Is there any way to pull data from a text box on form1 into form2

For example if Textbox1 = 100

When i click the botton to load form2-

Textbox1 on form 2 ALSO =100?

View 18 Replies

Centering Form2 Inside Form1

Aug 26, 2006

How I have centering Form2 inside Form1. CenterToParent() doesn't work.

View 14 Replies

Data Xfer From Form1 To Form2?

Mar 4, 2009

Is there an easy way (if it can be done at all) of taking data from textbox1 on form1 and placing it into textbox1 on form2?

SO when you hit the button it loads form two and will display the info stored on the origional form1?

View 15 Replies

DataSet On Form1 Not Visible On Form2?

Jan 6, 2010

Using VS2008 I created a dataset in the designer and created a table with one column in the dataset. I pulled this table to create a DGV on Form1 and my column appeared (DS & BS were created on the form as well). It is on Form1 that I would like to initially populate the DT. (The DS is internal and does not have a connection string) On Form2 I would like to create a DGV and use the BS on Form1 as the data source. This is not visible, however, from Form2. I can set the data source programatically but then the column is not visible on Form2 until run time and I would like to make my formatting changes on Form2 using the designer. I tried making the DS and BS on Form1 both public but they still are not visible as a data source on the Form2 DGV.Is there a way to make a data source on a form visible to other forms in the project using the designer?

View 3 Replies

Form2 Not Exceed Form1 Location

Sep 4, 2011

I want to create Program which have 2 forms. I want Form2 not out of Form1 region. Example: I have a form with a button. Button1 = Form.show Form2 appear on center the screen and can not exceed size of Form1.

View 2 Replies

Send A Variable From Form1 To Form2?

Jul 28, 2009

I have looked around and I can not find what I am looking for. I would like to send a variable from Form1 to Form2. I have found out how to send I text box from form1 to form2

How can I send a var from From1 to From2?

View 2 Replies

Show Form1 If Form2 Close

May 10, 2010

I am having a problem with the form. I want to make that if the form2 close, the form1 will be shown. I've tryed this code but it doesn't work.

If me.close then
form1.show

View 6 Replies

VS 2008 - Run Sub Created In Form1 From Form2

Mar 17, 2009

I am in the process of creating an excel add-in. I have created a subroutine inside one form. Using a second form, I would like to run the subrountine if the "OK" button is clicked. How do I make this public subroutine availiable between forms?

View 2 Replies







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