i want to access the parent control in the constructor

A

Antuane

hi guys, its me again, with a few simple (probably silly) quesetion...

hi guys, i've managed to create a custom textbox class.
& i'd like to access the parent control (in this case this would be the
form, cuz i drop the textbox onto the form), in the constructor of the
custom textbox class.

i'd like to access the parent control in the constructur of the textbox.
But i can't do this, cuz i get an error, saying that the parent property is
not initialized.
Error Message = Additional information: Object reference not set to an
instance of an object

But once the control is instantiated, i can access use this property to
access the parent object.

How can i access the parent object, in the constructor of my user control???
 
K

Ken Tucker [MVP]

Hi,

You do not have access to the controls parent until the
parentchanged event is fired.

Ken
----------------------
hi guys, its me again, with a few simple (probably silly) quesetion...

hi guys, i've managed to create a custom textbox class.
& i'd like to access the parent control (in this case this would be the
form, cuz i drop the textbox onto the form), in the constructor of the
custom textbox class.

i'd like to access the parent control in the constructur of the textbox.
But i can't do this, cuz i get an error, saying that the parent property is
not initialized.
Error Message = Additional information: Object reference not set to an
instance of an object

But once the control is instantiated, i can access use this property to
access the parent object.

How can i access the parent object, in the constructor of my user control???
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top