J
Joe Keller
Hello,
I'm creating a custom text control (derived from "TextBox") that in turn
creates a Combo Box control when the custom text control is instantiated.
If I attempt to set the parent of the Combo Box control during the "Create"
method of my custom Text Box, I get a NULL reference error telling me that
the "Parent" property of my Text Box control is NULL (which it indeed is at
this point). I got around this issue by overriding the "OnParentChanged"
method of my custom Text Box control and setting the parent property of my
Combo Box control within that method.
The question I have is, where is the proper place to set the parent properly
in this circumstance? Is there a better way than overriding the
"OnParentChanged" method?
I use the following code to set the parent of my Combo Box control to the
same parent of my Text Box control (remember, the Combo Box control is
instantiated from within the code of the Text Box control):
"this.Parent.Controls.Add(m_ComboBox);"
Thanks!
Joe
I'm creating a custom text control (derived from "TextBox") that in turn
creates a Combo Box control when the custom text control is instantiated.
If I attempt to set the parent of the Combo Box control during the "Create"
method of my custom Text Box, I get a NULL reference error telling me that
the "Parent" property of my Text Box control is NULL (which it indeed is at
this point). I got around this issue by overriding the "OnParentChanged"
method of my custom Text Box control and setting the parent property of my
Combo Box control within that method.
The question I have is, where is the proper place to set the parent properly
in this circumstance? Is there a better way than overriding the
"OnParentChanged" method?
I use the following code to set the parent of my Combo Box control to the
same parent of my Text Box control (remember, the Combo Box control is
instantiated from within the code of the Text Box control):
"this.Parent.Controls.Add(m_ComboBox);"
Thanks!
Joe