Jump to content
  • Advertisement
Sign in to follow this  
kag1

[.net] Controls Getting out of each others ways?

This topic is 4819 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I'm making an app in C#. This app involves a custom control, acutally an array of this custom control..There could be as many as a hundred our as few as one. I want this control to have a "Show" and "Hide" button, where when you push Hide, the control's height changes to about 25 pixels, so you can only see the show and hide buttons. But when the show is pressed, it expands to it's normal 300 pixel height. The purpose of this is so I can fit more and see more on the screen. There is very similar to how Google handles their email (like with the tabs, and when you click a tab it expands) My problem is that when I hit my show button, it expands right on top of the other controls. I want the other controls to realize that in order to be seen, they must move down the screen. How would I do this? Thank You.

Share this post


Link to post
Share on other sites
Advertisement
Could you show us some code? It's not very clear if you're coding for the web or for a windows forms app...

Cheers

Share this post


Link to post
Share on other sites
Of course, you have to move the other controls up/down when you contract/expand one of them. Controls are not aware of their siblings (other controls at the same level in the hierarchy).

This would be the responsibility of the container control to adjust each control's size and position. You are lucky, .NET 2.0 has a control that would do that right out of the Box: the FlowLayoutPanel. Use a vertical flow, and everything will work.

Now, I'm not sure if this solution would be very efficient speed- and memory-wise. You should do some experiments, but moving 100 controls each time the first ones are expanded or collapsed don't seem to be very effective to me. Maybe I'm wrong, so you better try and see for yourself.

In case the performances are too bad, you will have to build your own custom container. One that takes a control template (your child control), and instantiate only as many controls as could be seen. It would then reuse them for different instances (obvisouly moving them around). I hope I'm clear enough, because it's not very easy to describe with words (although the idea is very simple).

Good luck,
jods

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!