I would like to convert Control objects wich are in my array to progress bar Objects if possible. I know that the reverse conversion can be done explicitly without a problem but this one seems tricky. If impossible then please suggest something else instead. TNX

Recommended Answers

All 2 Replies

You'll have to explain more what you want. Progress Bar object that are referenced as Control objects can be converted with an explicit cast. If they aren't Progress Bar objects, they can't.

Tnx Momerath for pointing things out. I tried again and it worked
this is the code:

 public void AccessPb()
     {
            foreach (Control gb in this.Controls)
            {
                if (gb.HasChildren)
                {
                    foreach (Control pb in gb.Controls)
                    {
                        if (pb is ProgressBar)
                        {
                            list.Add((ProgressBar)pb);
                        }
                    }
                }
            }
       }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.