C # using SplitContainer controls to make shrink-expand panels

Source: Internet
Author: User

C # using SplitContainer controls to make shrink-expand panelsoriginal July 19, 2011 17:18:02
    • Label:
    • C #/
    • Object/
    • Extension
    • Test
    • 15690
Recently, squid ink on a PC-side software system on a contraction stretch panel is very interested in, plus their own inkjet machine data Management system interface is very monotonous, want to on the basis of the current interface to add this function. I personally just write a C # rookie, on the Internet to check a lot of C # control, many people are implemented with GroupBox and SplitContainer, so the two controls are tested.
Interface effect with squid ink company software:

First say GroupBox This control, this basically can realize the function that the panel expands and expand, but the personal feeling groupbox its itself that box feels not very good, plus I want to add scaling and expand the icon in the click Place, And the mouse on the click will become the hand type (GroupBox words mouse over the entire control will become hand type, not just the title), so do not delve into the box can be removed.

To search the Internet again. SplitContainer the use of this control, the control has a total of two panels, many people on the web with this control is the use of click on the first panel, hide the second Panel method:

[CSharp]View PlainCopy
  1. Private void Splitcontainer_panel1_mouseclick (object sender, MouseEventArgs e)
  2. {
  3. int i;
  4. Splitterpanel Splitpanel = (splitterpanel) sender;
  5. For (i = 0; i <; i++)
  6. if (Splitcontainers[i]. Panel1 = = Splitpanel)
  7. Break ;
  8. Splitcontainers[i]. panel2collapsed =!splitcontainers[i]. panel2collapsed;
  9. }

First in the first panel to add a mouse click event, the second panel by clicking on the expansion and expansion, because the listener is the first panel, and the second panel hides the need to splitcontainer the entire control of the variable, So I added all the splitcontainer inside the form to the splitcontainers array. If there is only one SplitContainer control that needs to be hidden, then this function is basically possible, but if there are multiple panels that need to be hidden, the layout of this method can be cumbersome because the second panel is just hiding, not disappearing, When the second panel position is followed up, the overlay of the control problem occurs. If a friend solves the problem, you can give me a hint.

It was the dead of the rope, and an unexpected thought suddenly appeared in my mind. Actually, I've been clutching splitcontainer. This control's panel hiding function is not put, in another way, we can set the size of the SplitContainer control directly like GroupBox:

[CSharp]View PlainCopy
  1. Private void Splitcontainer_panel1_mouseclick (object sender, MouseEventArgs e)
  2. {
  3. int i;
  4. Splitterpanel Splitpanel = (splitterpanel) sender;
  5. For (i = 0; i <; i++)
  6. if (Splitcontainers[i]. Panel1 = = Splitpanel)
  7. Break ;
  8. //splitcontainers[i]. panel2collapsed =!splitcontainers[i].  panel2collapsed;
  9. if (Splitcontainers[i]. Size.Height <=)
  10. {
  11. Splitcontainers[i]. Size = Containersizes[i];
  12. Splitcontainers[i]. Panel1.backgroundimage = Global::inkjet. Properties.resources. Expand;
  13. }
  14. Else
  15. {
  16. Splitcontainers[i]. Size = new Size (Splitcontainers[i].  Size.width, 20);
  17. Splitcontainers[i]. Panel1.backgroundimage = Global::inkjet. Properties.resources. Contraction;
  18. }
  19. }

It turns out that after re-setting the size of the SplitContainer, modifying the position of the SplitContainer control below can be a good fit for my needs. Later I found that putting all the SplitContainer controls inside the FlowLayoutPanel, after modifying the size of the SplitContainer control, would solve the problem without having to modify the position.

Report:

Of course the color of the interface needs to be perfected, the expansion and contraction of the icon is from the squid ink company software. But has been able to meet the needs of the software, if passing friends have a better way, welcome guidance.

C # using SplitContainer controls to make shrink-expand panels

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.