I have a question, I have a working application. I am using a splitcontainer with multiple different Panels inside of it. When a user clicks a button the following code is executed:

this->panelnameA->Visible = true;
this->panelnameB->Visible = false;
this->panelnameC->Visible = false;

Now my question is lets say an application has 10 different panels. Is there an easier way to do the code?

So say like you can make it

this->panelnameB,panelnameC->Visible = false;

Or even better could you manage all the panels under one grouping so you could just write

this->closesubpanels->Visible = false;

I'll relate the second request to what I know which is PHP...you could create a string variable containing all the panels you would want to close then you would just call the string to close all the windows instead of creating a line for each panel which is monotonous and could generate a thousand extra lines of code.

Any ideas? Or have I lost people?

I guess secondarily while I think about it, if you can create a string type to hold all the panels....Could you then include every panel and thus restructure the code as follows:

this->panelstring->Visible = false;
this->panelnameA->Visible = true;

This way you could include all the panels into the string and they will all close but only the panel you want will open. Or does this have to be achieve through another way?

Recommended Answers

Answered by thines01 401 in a post from

You could put them in a List<Panbel^>^ and do a "for each" on it.

Jump to Post

All 4 Replies

You could put them in a List<Panbel^>^ and do a "for each" on it.

Thank you for the response Thines, I'll try it out when I get home tonight from work.

Did it work?

It did and it didn't thats why I still gave you reputation for your post. It was an interesting little trick it just didn't quite work the way I required it too.

I do thank you though Thines because you have been outstanding at answering my C++/CLI issues, where you ever learned this much about C++/CLI you gotta send me the link and/or the book(s).

Be a part of the DaniWeb community

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