471,317 Members | 1,889 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,317 software developers and data experts.

How to get component in winforms

Hi all,

I have a Parent Form, and several child forms extends from this Parent
Form. I would instantiate the child forms and return as Parent Form
(factory methods).

In the Parent Form there is a method which I need to dynamically close
all the connection associated with OleDbCommand.

The original code from Borland C++ builder:

['this' refer to current windows form]
// For all the components on the form
for (int i = 0; i < this->ComponentCount; i++)
{
TComponent *comp = this->Components[i];
TADOQuery *form_query = dynamic_cast<TADOQuery *>(comp);

if (form_query != NULL)
{
form_query->Close();
}
} // for

I used something like 'this.Container.Components' to refer to my
component, but it give me an error object reference not set to an
instance of object. When I checked, even 'this.Container' is null. Is
there other approach to dynamically get my components?

regards & thanks,
john

Feb 23 '06 #1
0 892

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

12 posts views Thread by Chien Lau | last post: by
6 posts views Thread by TnCoder | last post: by
1 post views Thread by Greg Busby | last post: by
1 post views Thread by Mark | last post: by
reply views Thread by jean | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.