Click here to Skip to main content
15,892,161 members
Home / Discussions / C#
   

C#

 
GeneralRe: change text from form Pin
messages25-Nov-13 5:19
messages25-Nov-13 5:19 
GeneralRe: change text from form Pin
OriginalGriff25-Nov-13 5:23
mveOriginalGriff25-Nov-13 5:23 
GeneralRe: change text from form Pin
messages25-Nov-13 5:48
messages25-Nov-13 5:48 
GeneralRe: change text from form Pin
OriginalGriff25-Nov-13 6:00
mveOriginalGriff25-Nov-13 6:00 
GeneralRe: change text from form Pin
messages25-Nov-13 6:32
messages25-Nov-13 6:32 
GeneralRe: change text from form Pin
OriginalGriff25-Nov-13 7:59
mveOriginalGriff25-Nov-13 7:59 
GeneralRe: change text from form Pin
messages26-Nov-13 3:59
messages26-Nov-13 3:59 
GeneralRe: change text from form Pin
OriginalGriff26-Nov-13 5:01
mveOriginalGriff26-Nov-13 5:01 
You use a property to access the data, but you use an Event to tell the other form when you have new data for it.

Think about it: the logic needs to be that the user types on one form, and presses a button. The text needs to be available via a property (or the other form can't access it) but the other form needs to know when the user has finished typing and pressed the button! So you have a property to get the data, and a event to tell you when to read it.

A property is easy to define:
C#
public string MyProperty
   {
   get { return myTextBox.Text; }
   set { myTextBox.Text = value; }
   }
Declares a property of type "string" called MyProperty, that Form1 can access:
C#
Form2 f2 = new Form2();
f2.MyProperty = "hello!";
...

GeneralRe: change text from form Pin
messages26-Nov-13 5:22
messages26-Nov-13 5:22 
GeneralRe: change text from form Pin
OriginalGriff26-Nov-13 5:56
mveOriginalGriff26-Nov-13 5:56 
AnswerRe: change text from form Pin
BillWoodruff25-Nov-13 5:08
professionalBillWoodruff25-Nov-13 5:08 
GeneralRe: change text from form Pin
messages25-Nov-13 5:26
messages25-Nov-13 5:26 
GeneralRe: change text from form Pin
BillWoodruff25-Nov-13 12:39
professionalBillWoodruff25-Nov-13 12:39 
AnswerRe: change text from form Pin
Vinh Nguyen26-Nov-13 0:01
Vinh Nguyen26-Nov-13 0:01 
QuestionHow can I access the properties of this object? Pin
turbosupramk325-Nov-13 3:20
turbosupramk325-Nov-13 3:20 
AnswerRe: How can I access the properties of this object? Pin
Vinh Nguyen25-Nov-13 3:52
Vinh Nguyen25-Nov-13 3:52 
AnswerRe: How can I access the properties of this object? Pin
OriginalGriff25-Nov-13 5:10
mveOriginalGriff25-Nov-13 5:10 
AnswerRe: How can I access the properties of this object? Pin
turbosupramk325-Nov-13 5:54
turbosupramk325-Nov-13 5:54 
AnswerRe: How can I access the properties of this object? Pin
Abhinav S25-Nov-13 6:35
Abhinav S25-Nov-13 6:35 
GeneralRe: How can I access the properties of this object? Pin
turbosupramk325-Nov-13 7:13
turbosupramk325-Nov-13 7:13 
AnswerRe: How can I access the properties of this object? Pin
Richard Deeming25-Nov-13 8:56
mveRichard Deeming25-Nov-13 8:56 
GeneralRe: How can I access the properties of this object? Pin
turbosupramk325-Nov-13 9:02
turbosupramk325-Nov-13 9:02 
GeneralRe: How can I access the properties of this object? Pin
Richard Deeming25-Nov-13 9:07
mveRichard Deeming25-Nov-13 9:07 
QuestionMemory Usage from Task Manager Pin
devvvy24-Nov-13 13:06
devvvy24-Nov-13 13:06 
AnswerRe: Memory Usage from Task Manager PinPopular
Dave Kreskowiak24-Nov-13 18:05
mveDave Kreskowiak24-Nov-13 18:05 

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.