WinForm form imitating QQ panel

Description of the WinForm form imitating the QQ panel
    : A few days ago, I saw a very beautiful enterprise instant messaging software from a friend. It was written in C#, and the effect similar to the QQ panel was achieved without using third-party controls at all. very beautiful.
    After returning home, I tried to achieve it with my own memory and consulting MSDN, and initially achieved a similar effect, and now I dedicate it to everyone.
    There are three controls (excluding form classes) used in the program: ImageList, Button and ListView. The Button control displays the friend group, and after clicking, the information of the corresponding friend group is displayed; the ImageList control is used to store the friend’s avatar; the ListView control is used to display the friend list. In the program, instead of using Location to locate the position of the control, use the Dock property to set the docking of the control and adjust the size together with the parent control.

Program core code:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace QQPanelDemo
{
    ///  
    /// Description: A few days ago, I saw a very beautiful enterprise instant messaging software from a friend. It was written in C#, and it achieved the effect similar to the QQ panel without using third-party controls at all. It is very pretty. 
    /// After returning home, I tried to achieve it with my own memory and consulting MSDN, and initially achieved a similar effect, and now I dedicate it to everyone. 
    /// Three controls (excluding form classes) are used in the program: ImageList, Button and ListView. 
    /// The Button control displays the friend group, and after clicking, the information of the corresponding friend group is displayed; the ImageList control is used to store the friend's avatar; the ListView control is used to display the friend list. 
    /// In the program, instead of using Location to locate the position of the control, use the Dock property to set the docking of the control and adjust the size together with the parent control. 
    /// Author: Zhou Gong 
    /// Date: 2008-5-31 
    /// 
     public  partial  class  MainForm : Form
    {
        public MainForm()
        {
            InitializeComponent();
        }
        //Show my friend list menu 
        private  void  btnMyFriend_Click ( object sender, EventArgs e )
        {
            //set the dock
            listView.Dock = DockStyle.None;
            btnMyFriend.Dock = DockStyle.Top;
            btnMyColleague.Dock = DockStyle.Bottom;
            btnMyStranger.SendToBack();
            btnMyStranger.Dock = DockStyle.Bottom;
            listView.BringToFront();
            listView.Dock = DockStyle.Bottom;
            //add item
            listView.Clear();
            listView.Items.Add( "Wife" , "Wife" , 5 );
            listView.Items.Add( "Xiaomi" , "Xiaomi" , 1 );
            listView.Items.Add( "Zhou Gong" , "Zhou Gong" , 7 );
            listView.Items.Add( "Lover" , "Lover" , 7 );
            listView.Items.Add( "Lili" , "Lili" , 6 );
            listView.Items.Add( "Flower" , "Flower" , 8 );
            listView.Items.Add( "Babe" , "Babe" , 9 );
        }

        private void MainForm_Load(object sender, EventArgs e)
        {
            //set the dock
            listView.Dock = DockStyle.None;
            btnMyFriend.Dock = DockStyle.Top;
            btnMyColleague.Dock = DockStyle.Bottom;
            btnMyStranger.SendToBack();
            btnMyStranger.Dock = DockStyle.Bottom;
            listView.BringToFront();
            listView.Dock = DockStyle.Bottom;
            //add item
            listView.Clear();
            listView.LargeImageList = imageList;
            listView.Items.Add( "Wife" , "Wife" , 5 );
            listView.Items.Add( "Xiaomi" , "Xiaomi" , 1 );
            listView.Items.Add( "Lili" , "Lili" , 4 );
            listView.Items.Add( "Zhou Gong" , "Zhou Gong" , 7 );
            listView.Items.Add( "Lover" , "Lover" , 7 );
            listView.Items.Add( "Flower" , "Flower" , 8 );
            listView.Items.Add( "Babe" , "Babe" , 9 );
        }
        //Show my stranger menu 
        private  void  btnMyStranger_Click ( object sender, EventArgs e )
        {
            //set the dock
            listView.Dock = DockStyle.None;
            btnMyStranger.SendToBack();
            btnMyStranger.Dock = DockStyle.Top;
            btnMyColleague.SendToBack();
            btnMyColleague.Dock = DockStyle.Top;
            btnMyFriend.SendToBack();
            btnMyFriend.Dock = DockStyle.Top;
            listView.Dock = DockStyle.Top;
            Add item
            listView.Clear();
            listView.Items.Add( "Friends" , "Friends" , 16 );
            listView.Items.Add( "Card Friends" , "Card Friends" , 14 );
            listView.Items.Add( "Friends" , "Friends" , 15 );
            listView.Items.Add( "Blowing Friends" , "Blowing Friends" , 12 );
            listView.Items.Add( "Kanyou" , "Kanyou" , 11 );
            listView.Items.Add( "ALICE" , "ALICE" , 9 );
            listView.Items.Add( "Book Friends" , "Book Friends" , 10 );
            listView.Items.Add( "Penpal" , "Penpal" , 13 );
        }
        //Show my colleague menu 
        private  void  btnMyColleague_Click ( object sender, EventArgs e )
        {
            //set the dock
            listView.Dock = DockStyle.None;
            btnMyColleague.Dock = DockStyle.Top;
            btnMyFriend.SendToBack();
            btnMyFriend.Dock = DockStyle.Top;
            btnMyStranger.Dock = DockStyle.Bottom;
            listView.Dock = DockStyle.Bottom;
            listView.BringToFront();
            Add item
            listView.Items.Clear();
            listView.Items.Add( "Boss" , "Boss" , 2 );
            listView.Items.Add( "Chairman" , "Chairman" , 3 );
            listView.Items.Add( "Group Leader" , "Group Leader" , 4 );
            listView.Items.Add( "Squad Leader" , "Squad Leader" , 17 );
            listView.Items.Add( "Women's Director" , "Women's Director" , 16 );
            listView.Items.Add( "Administrator" , "Administrator" , 15 );
            listView.Items.Add( "Aunt Lou Road" , "Aunt Lou Road" , 2 );
            listView.Items.Add( "Officer" , "Officer" , 3 );
            listView.Items.Add( "Manager Office" , "Manager Office" , 4 );
            listView.Items.Add( "Party Committee Office" , "Party Committee Office" , 17 );
            listView.Items.Add( "Propaganda Office" , "Propaganda Office" , 16 );
            listView.Items.Add( "Retirement Office" , "Retirement Office" , 15 );
        }
    }
}

Program running effect:

Leave a Comment

Your email address will not be published. Required fields are marked *