Click here to Skip to main content
15,886,830 members
Home / Discussions / C#
   

C#

 
GeneralRe: Exit from main Pin
Heath Stewart26-Jan-04 4:08
protectorHeath Stewart26-Jan-04 4:08 
Questionhacked? Pin
Anonymous26-Jan-04 2:47
Anonymous26-Jan-04 2:47 
AnswerRe: hacked? Pin
Thesisus26-Jan-04 3:05
Thesisus26-Jan-04 3:05 
GeneralRe: hacked? Pin
Heath Stewart26-Jan-04 3:10
protectorHeath Stewart26-Jan-04 3:10 
GeneralRe: hacked? Pin
Anonymous31-Jan-04 1:16
Anonymous31-Jan-04 1:16 
GeneralParentForm and a null reference Pin
Andrew McLellan26-Jan-04 1:47
Andrew McLellan26-Jan-04 1:47 
GeneralRe: ParentForm and a null reference Pin
Broken God26-Jan-04 2:06
Broken God26-Jan-04 2:06 
GeneralRe: ParentForm and a null reference Pin
AWoodgate26-Jan-04 6:23
AWoodgate26-Jan-04 6:23 
I'm not doing any of this in the constructor.

A simple case is:

I have 2 forms

Form1 has a public string, myString, initialised with "ABCDEF". It also has a button that when clicked loads Form2:
<br />
private void button1_Click(object sender, System.EventArgs e)<br />
{<br />
    Form2 frm = new Form2();<br />
    frm.Show();<br />
}


Form2 has a label on it, in the label's 'Click' event I try to set it's Text with the following:

void label1_Click(object sender, System.EventArgs e)<br />
{<br />
    label1.Text = ((Form1)this.ParentForm).myString;<br />
}


This causes the NullReferenceException and when I highlight 'this.ParentForm', it shows as <undefined value="">

Why?
GeneralRe: ParentForm and a null reference Pin
Broken God27-Jan-04 8:32
Broken God27-Jan-04 8:32 
General.NET Serialization and versioning Pin
dabs26-Jan-04 1:04
dabs26-Jan-04 1:04 
GeneralRe: .NET Serialization and versioning Pin
Heath Stewart26-Jan-04 2:18
protectorHeath Stewart26-Jan-04 2:18 
GeneralGDI+ Problem Pin
occcy26-Jan-04 0:02
occcy26-Jan-04 0:02 
GeneralRe: GDI+ Problem Pin
Broken God26-Jan-04 2:10
Broken God26-Jan-04 2:10 
GeneralRe: GDI+ Problem Pin
occcy26-Jan-04 2:13
occcy26-Jan-04 2:13 
GeneralRe: GDI+ Problem Pin
Heath Stewart26-Jan-04 3:04
protectorHeath Stewart26-Jan-04 3:04 
GeneralRe: GDI+ Problem Pin
Heath Stewart26-Jan-04 3:09
protectorHeath Stewart26-Jan-04 3:09 
GeneralRe: GDI+ Problem Pin
leppie26-Jan-04 6:06
leppie26-Jan-04 6:06 
GeneralSharing process resources Pin
Jucovschi Petru25-Jan-04 22:57
Jucovschi Petru25-Jan-04 22:57 
GeneralRe: Sharing process resources Pin
OmegaSupreme26-Jan-04 0:57
OmegaSupreme26-Jan-04 0:57 
GeneralOrganization of ideas Pin
Shree25-Jan-04 21:01
Shree25-Jan-04 21:01 
GeneralRe: Organization of ideas Pin
Colin Angus Mackay26-Jan-04 1:00
Colin Angus Mackay26-Jan-04 1:00 
GeneralProblem about IP Multicast Pin
Korby25-Jan-04 18:22
Korby25-Jan-04 18:22 
GeneralRe: Problem about IP Multicast Pin
Heath Stewart26-Jan-04 3:02
protectorHeath Stewart26-Jan-04 3:02 
GeneralMultithreading issue Pin
maria_p25-Jan-04 8:51
maria_p25-Jan-04 8:51 
GeneralRe: Multithreading issue Pin
Colin Angus Mackay25-Jan-04 11:22
Colin Angus Mackay25-Jan-04 11:22 

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.