C # winform navigation interface .. use groupbox, button and listview for winform

Source: Internet
Author: User

Winform uses buttons and listview to implement navigation menus similar to QQ settings.

DockStyle is mainly used.

The specific code is as follows:
(Note) Pay special attention to the order in which controls are created.
The order in which controls are created is as follows (in. Design. cs ):
 
[Csharp]
This. groupBox1 = new System. Windows. Forms. GroupBox ();
This. button1 = new System. Windows. Forms. Button ();
This. button2 = new System. Windows. Forms. Button ();
This. button3 = new System. Windows. Forms. Button ();
This. button4 = new System. Windows. Forms. Button ();
This. button5 = new System. Windows. Forms. Button ();
This. button6 = new System. Windows. Forms. Button ();
This. listView1 = new System. Windows. Forms. ListView ();


 

The main code is as follows:
// Use listview and six buttons to implement navigation menu functions | Yes

[Csharp]
Private void button#click (object sender, EventArgs e)
{
ResetButton (); // reset button
 
 
ListView1. Dock = DockStyle. None;
 
 
Button2. Dock = DockStyle. Bottom;
Button3. Dock = DockStyle. Bottom;
Button4. Dock = DockStyle. Bottom;
Button5. Dock = DockStyle. Bottom;
Button6. Dock = DockStyle. Bottom;
 
 
ListView1. BringToFront ();
ListView1. Dock = DockStyle. Bottom;
ListView1. Clear ();
}
 
 
Private void button2_Click (object sender, EventArgs e)
{
ResetButton (); // reset button
ListView1. Dock = DockStyle. None;
 
 
Button3. Dock = DockStyle. Bottom;
Button4. Dock = DockStyle. Bottom;
Button5. Dock = DockStyle. Bottom;
Button6. Dock = DockStyle. Bottom;
 
 
 
 
ListView1. BringToFront ();
ListView1. Dock = DockStyle. Bottom;
ListView1. Clear ();
 
 
}
 
 
Private void button3_Click (object sender, EventArgs e)
{
ResetButton (); // reset button
 
 
ListView1. Dock = DockStyle. None;
 
 
Button4. Dock = DockStyle. Bottom;
Button5. Dock = DockStyle. Bottom;
Button6. Dock = DockStyle. Bottom;
 
 
 
 
ListView1. BringToFront ();
ListView1. Dock = DockStyle. Bottom;
ListView1. Clear ();
}
 
 
Private void button4_Click (object sender, EventArgs e)
{
ResetButton (); // reset button
 
 
ListView1. Dock = DockStyle. None;
 
 
Button5. Dock = DockStyle. Bottom;
Button6. Dock = DockStyle. Bottom;
 
 
 
 
ListView1. BringToFront ();
ListView1. Dock = DockStyle. Bottom;
ListView1. Clear ();
}
 
 
Private void button5_Click (object sender, EventArgs e)
{
ResetButton (); // reset button
 
 
ListView1. Dock = DockStyle. None;
 
 
Button6. Dock = DockStyle. Bottom;
 
 
 
 
ListView1. BringToFront ();
ListView1. Dock = DockStyle. Bottom;
ListView1. Clear ();
}
 
 
Private void button6_Click (object sender, EventArgs e)
{
ResetButton (); // reset button
 
 
}
 
 
Public void ResetButton () // initialization settings
{
 
 
Button1. Dock = DockStyle. Bottom;
Button2. Dock = DockStyle. Bottom;
Button3. Dock = DockStyle. Bottom;
Button4. Dock = DockStyle. Bottom;
Button5. Dock = DockStyle. Bottom;
Button6. Dock = DockStyle. Bottom;
ListView1. Dock = DockStyle. Bottom;
 
 
ListView1. Dock = DockStyle. None;
Button1. Dock = DockStyle. None;
Button2. Dock = DockStyle. None;
Button3. Dock = DockStyle. None;
Button4. Dock = DockStyle. None;
Button5. Dock = DockStyle. None;
Button6. Dock = DockStyle. None;
 
 
}


The implementation result is as follows:

Related Article

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.