.NET Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgramming.NET Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old October 19th, 2003, 12:26 PM
mtzal mtzal is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 8 mtzal User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Unhappy c# windows Forms variables passing

Can anyone tell me a way to pass the text viariable of a textbox, named textBox1, in a form named Form1, to a textbox named textBox1 in form named Form2??

please Help...

Reply With Quote
  #2  
Old October 20th, 2003, 05:16 PM
rdoekes rdoekes is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Location: Strasbourg, France
Posts: 181 rdoekes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 m 20 sec
Reputation Power: 7
Send a message via AIM to rdoekes Send a message via Yahoo to rdoekes
Are those forms in the same page?

If not, and you submit first form to a new webform, you could assign the form element to the second form element in the page_unload sub
__________________
- Rogier Doekes

Reply With Quote
  #3  
Old October 21st, 2003, 04:08 PM
digitallysmooth digitallysmooth is offline
you know how we do
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jun 2002
Posts: 788 digitallysmooth User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 34 m 21 sec
Reputation Power: 7
Ok, so you are having trouble passing info from one form to the next.

I love how OO programming brings in that extra level of protection.

You just need to modify the access level of textBox1 in Form2 to 'protected internal'.

The code to pass the information over is:
Code:
Form2 f2 = new Form2();
f2.Show();
f2.textBox1.Text = textBox1.Text;
__________________
__________________________________________________ _
Wil Moore III, MCP | Integrations Specialist | Senior Consultant
Are You Listed...? | DigitallySmooth Inc.

Reply With Quote
  #4  
Old October 21st, 2003, 04:09 PM
digitallysmooth digitallysmooth is offline
you know how we do
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jun 2002
Posts: 788 digitallysmooth User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 34 m 21 sec
Reputation Power: 7
BTW, the above code assumes you are writing code for an event of a control that is in Form1 and Form1 has a textbox named textBox1.

Reply With Quote
  #5  
Old November 26th, 2004, 12:18 PM
rhinton rhinton is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 19 rhinton User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 15 m 41 sec
Reputation Power: 0
You also may add a module to your project and declare all the variables that you want passed from form to form as Public in that module. That way you can call it anytime.

Reply With Quote
  #6  
Old October 10th, 2005, 12:35 PM
cvncpu cvncpu is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2005
Posts: 1 cvncpu User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 22 m 58 sec
Reputation Power: 0
Quote:
Originally Posted by rhinton
You also may add a module to your project and declare all the variables that you want passed from form to form as Public in that module. That way you can call it anytime.


I am trying to do something similar, how would I create a "module" and have global variables, that can be accessed from all forms in a solution?

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgramming.NET Development > c# windows Forms variables passing


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT