Null reference

Posts 1–5 of 5 · Page 1 of 1
Null reference
Code:
Private WithEvents comp As DigitalRune.Windows.TextEditor.TextEditorControl = Me.TabControl1.SelectedTab.Controls(0)
In the first tab of that control there's a text editor, so why the hell does it throws a exception?
View GpS2S0.png on ScreenSnapr
Try changing the declaration to this:

[highlight=vb]Private WithEvents comp As DigitalRune.Windows.TextEditor.TextEditorControl[/highlight]

And in Form1's load event, initialize the comp:

[highlight=vb]comp = Me.TabControl1.SelectedTab.Controls(0)[/highlight]

If the above line doesn't works, try casting:

[highlight=vb]Dim TxtEd As DigitalRune.Windows.TextEditor.TextEditorControl = Me.TabControl1.SelectedTab.Controls(0)[/highlight]
Initializing in the load event, well thank you master <3
No Prob ^^
Just to let you know why it didn't work is because the nested/child control did not exist when the comp object was initialized so the *********enceException was thrown.
Posts 1–5 of 5 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Need help?