Click here to Skip to main content
15,908,768 members
Home / Discussions / C#
   

C#

 
QuestionColor Wheel [modified] Pin
Cerasti28-May-06 7:23
Cerasti28-May-06 7:23 
AnswerRe: Color Wheel [modified] Pin
Robert Rohde28-May-06 11:20
Robert Rohde28-May-06 11:20 
GeneralRe: Color Wheel [modified] Pin
Cerasti29-May-06 4:37
Cerasti29-May-06 4:37 
GeneralRe: Color Wheel [modified] Pin
Cerasti6-Jun-06 6:18
Cerasti6-Jun-06 6:18 
QuestionPassing value from form to an active form Pin
JelleM28-May-06 6:27
JelleM28-May-06 6:27 
AnswerRe: Passing value from form to an active form [modified] Pin
StevenS_Dev28-May-06 7:26
StevenS_Dev28-May-06 7:26 
GeneralRe: Passing value from form to an active form Pin
JelleM28-May-06 7:34
JelleM28-May-06 7:34 
AnswerRe: Passing value from form to an active form [modified] Pin
Alex B. Clarke28-May-06 7:59
Alex B. Clarke28-May-06 7:59 
Create a win app project
with two Froms : Form1 and Form2
In the Main() have Form1 as a parameter in Application.Run() method, like so
static void Main(string[] args) {
   Application.Run(new Form1());
}

In The Second Form
Add a Button and a TextBox control.

Add public property that will be accessed from Form1 to retrieve a value assigned in Form2. I used string but of course you can use whatever type you need.
public string FormVariable {
   get {
      return Int32.Parse(this.txtIntValue.Text);
   }
}

Code button click event
private void button1_Click(object sender, System.EventArgs e) {
   this.DialogResult = DialogResult.OK;
}

In The First Form
Add a Button and code its click event.
private void button1_Click(object sender, System.EventArgs e) {
   using (Form2 frm2 = new Form2()) {
      System.Windows.Forms.DialogResult dr = frm2.ShowDialog(this);
      string result = frm2.FormVariable;
      MessageBox.Show("Form2 variable value: " + result, 
      "Message Called from  Form1");
   }
}


Run The App
Form1 will get displayed, click on its button.
Form2 will get displayed.
In Form2 type a value in the TextBox and click on the button.
Form2 will close and you'll see a message box showing you the value you typed in Form2.

This is obviously one of the possible solutions...
Let me know if it helps or if you have any queries.

Alex B. Clarke


-- modified at 14:04 Sunday 28th May, 2006
GeneralRe: Passing value from form to an active form [modified] Pin
JelleM28-May-06 9:31
JelleM28-May-06 9:31 
GeneralRe: Passing value from form to an active form [modified] Pin
Alex B. Clarke28-May-06 10:06
Alex B. Clarke28-May-06 10:06 
GeneralRe: Passing value from form to an active form [modified] Pin
StevenS_Dev28-May-06 14:46
StevenS_Dev28-May-06 14:46 
Questiondelete Pin
kjosh28-May-06 5:55
kjosh28-May-06 5:55 
AnswerRe: delete Pin
WillemM28-May-06 6:54
WillemM28-May-06 6:54 
AnswerRe: delete Pin
JelleM28-May-06 6:54
JelleM28-May-06 6:54 
QuestionWhy new node in TreeList not can have focus? Pin
Dima Filipiuk28-May-06 5:46
Dima Filipiuk28-May-06 5:46 
AnswerRe: Why new node in TreeList not can have focus? Pin
stancrm28-May-06 21:13
stancrm28-May-06 21:13 
GeneralRe: Why new node in TreeList not can have focus? [modified] Pin
Dima Filipiuk29-May-06 0:45
Dima Filipiuk29-May-06 0:45 
QuestionTrigger event when a process exits Pin
Mridang Agarwalla28-May-06 2:47
Mridang Agarwalla28-May-06 2:47 
AnswerRe: Trigger event when a process exits Pin
Guffa28-May-06 4:04
Guffa28-May-06 4:04 
AnswerRe: Trigger event when a process exits Pin
leppie28-May-06 4:11
leppie28-May-06 4:11 
Questionhow to get password textbox in asp.net Pin
foysal mamun27-May-06 23:30
foysal mamun27-May-06 23:30 
AnswerRe: how to get password textbox in asp.net Pin
Billah28-May-06 0:44
Billah28-May-06 0:44 
GeneralRe: how to get password textbox in asp.net Pin
foysal mamun28-May-06 20:57
foysal mamun28-May-06 20:57 
QuestionSend sms from internet ? [modified] Pin
hasan_hasany27-May-06 23:13
hasan_hasany27-May-06 23:13 
AnswerRe: Send sms from internet ? [modified] Pin
hasan_hasany30-May-06 11:32
hasan_hasany30-May-06 11:32 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.