qq 的下拉菜单.

本文介绍了一个简单的QQ2008界面设计实例,包括好友、陌生人和黑名单按钮的操作及布局调整。通过按钮点击事件实现好友与陌生人之间的转换,并调整黑名单的位置。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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

namespace QQ3000
{
 /// <summary>
 /// Summary description for Form1.
 /// </summary>
 public class Form1 : System.Windows.Forms.Form
 {
  int a=88;
  int b=66;
  
  
  private System.Windows.Forms.GroupBox groupBox1;
  private System.Windows.Forms.Button 按钮_我的好友;
  private System.Windows.Forms.Button 按钮_陌生人;
  private System.Windows.Forms.Button 按钮_黑名单;
  private System.Windows.Forms.PictureBox pictureBox1;
  private System.Windows.Forms.PictureBox pictureBox2;
  private System.Windows.Forms.PictureBox pictureBox3;
  private System.Windows.Forms.Button button1;
    
  private int 陌生人
  {
   get
   {
    return 按钮_陌生人.Top;
   }
   set
   {
    if( value < 按钮_陌生人.Top )
    {
     按钮_陌生人.Top = 按钮_我的好友.Top + 按钮_我的好友.Height;
    }
    else
    {
     黑名单 ++;
     按钮_陌生人.Top = 按钮_黑名单.Top - 按钮_陌生人.Height;
    }
   }
  }
  private int 黑名单
  {
   get
   {
    return 按钮_黑名单.Top;
   }
   set
   {
    if( value < 按钮_黑名单.Top )
    {
     陌生人 --;
     按钮_黑名单.Top = 按钮_陌生人.Bottom + 1;
    }
    else
    {
     按钮_黑名单.Top = groupBox1.Height - 按钮_陌生人.Height-20;
    }
   }
  }
  /// <summary>
  /// Required designer variable.
  /// </summary>
  private System.ComponentModel.Container components = null;
  public Form1()
  {
   //
   // Required for Windows Form Designer support
   //
   int[,] ax=new int[2,2] {{1,2},{3,4}};
   InitializeComponent();
   int[,] ax1=new int[2,2] {{1,2},{3,4}};
   //
   // TODO: Add any constructor code after InitializeComponent call
   //
   System.Collections.Hashtable abc=new Hashtable();
  }

  /// <summary>
  /// Clean up any resources being used.
  /// </summary>
  protected override void Dispose( bool disposing )
  {
   if( disposing )
   {
    if (components != null)
    {
     components.Dispose();
    }
   }
   base.Dispose( disposing );
  }

  #region Windows Form Designer generated code
  /// <summary>
  /// Required method for Designer support - do not modify
  /// the contents of this method with the code editor.
  /// </summary>
  private void InitializeComponent()
  {
   System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));
   this.按钮_黑名单 = new System.Windows.Forms.Button();
   this.按钮_陌生人 = new System.Windows.Forms.Button();
   this.groupBox1 = new System.Windows.Forms.GroupBox();
   this.按钮_我的好友 = new System.Windows.Forms.Button();
   this.pictureBox1 = new System.Windows.Forms.PictureBox();
   this.pictureBox2 = new System.Windows.Forms.PictureBox();
   this.pictureBox3 = new System.Windows.Forms.PictureBox();
   this.button1 = new System.Windows.Forms.Button();
   this.groupBox1.SuspendLayout();
   this.SuspendLayout();
   //
   // 按钮_黑名单
   //
   this.按钮_黑名单.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    | System.Windows.Forms.AnchorStyles.Right)));
   this.按钮_黑名单.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(255)), ((System.Byte)(255)), ((System.Byte)(192)));
   this.按钮_黑名单.Location = new System.Drawing.Point(0, 56);
   this.按钮_黑名单.Name = "按钮_黑名单";
   this.按钮_黑名单.Size = new System.Drawing.Size(97, 27);
   this.按钮_黑名单.TabIndex = 2;
   this.按钮_黑名单.Text = "黑 名 单";
   this.按钮_黑名单.Click += new System.EventHandler(this.按钮_黑名单_单击);
   //
   // 按钮_陌生人
   //
   this.按钮_陌生人.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    | System.Windows.Forms.AnchorStyles.Right)));
   this.按钮_陌生人.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(255)), ((System.Byte)(255)), ((System.Byte)(192)));
   this.按钮_陌生人.Location = new System.Drawing.Point(0, 28);
   this.按钮_陌生人.Name = "按钮_陌生人";
   this.按钮_陌生人.Size = new System.Drawing.Size(97, 28);
   this.按钮_陌生人.TabIndex = 1;
   this.按钮_陌生人.Text = "陌 生 人";
   this.按钮_陌生人.Click += new System.EventHandler(this.按钮_陌生人_单击);
   //
   // groupBox1
   //
   this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    | System.Windows.Forms.AnchorStyles.Right)));
   this.groupBox1.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(128)), ((System.Byte)(128)), ((System.Byte)(255)));
   this.groupBox1.Controls.Add(this.按钮_黑名单);
   this.groupBox1.Controls.Add(this.按钮_陌生人);
   this.groupBox1.Controls.Add(this.按钮_我的好友);
   this.groupBox1.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
   this.groupBox1.Location = new System.Drawing.Point(0, 22);
   this.groupBox1.Name = "groupBox1";
   this.groupBox1.Size = new System.Drawing.Size(97, 360);
   this.groupBox1.TabIndex = 0;
   this.groupBox1.TabStop = false;
   this.groupBox1.Enter += new System.EventHandler(this.groupBox1_Enter);
   //
   // 按钮_我的好友
   //
   this.按钮_我的好友.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    | System.Windows.Forms.AnchorStyles.Right)));
   this.按钮_我的好友.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(255)), ((System.Byte)(255)), ((System.Byte)(192)));
   this.按钮_我的好友.Location = new System.Drawing.Point(0, 1);
   this.按钮_我的好友.Name = "按钮_我的好友";
   this.按钮_我的好友.Size = new System.Drawing.Size(97, 28);
   this.按钮_我的好友.TabIndex = 0;
   this.按钮_我的好友.Text = "我 的 好 友";
   this.按钮_我的好友.Click += new System.EventHandler(this.按钮_我的好友_单击);
   //
   // pictureBox1
   //
   this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image")));
   this.pictureBox1.Location = new System.Drawing.Point(11, 2);
   this.pictureBox1.Name = "pictureBox1";
   this.pictureBox1.Size = new System.Drawing.Size(28, 19);
   this.pictureBox1.TabIndex = 1;
   this.pictureBox1.TabStop = false;
   //
   // pictureBox2
   //
   this.pictureBox2.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox2.Image")));
   this.pictureBox2.Location = new System.Drawing.Point(39, 2);
   this.pictureBox2.Name = "pictureBox2";
   this.pictureBox2.Size = new System.Drawing.Size(20, 21);
   this.pictureBox2.TabIndex = 2;
   this.pictureBox2.TabStop = false;
   //
   // pictureBox3
   //
   this.pictureBox3.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox3.Image")));
   this.pictureBox3.Location = new System.Drawing.Point(70, 2);
   this.pictureBox3.Name = "pictureBox3";
   this.pictureBox3.Size = new System.Drawing.Size(25, 19);
   this.pictureBox3.TabIndex = 3;
   this.pictureBox3.TabStop = false;
   //
   // button1
   //
   this.button1.BackColor = System.Drawing.SystemColors.Info;
   this.button1.Location = new System.Drawing.Point(4, 384);
   this.button1.Name = "button1";
   this.button1.Size = new System.Drawing.Size(100, 25);
   this.button1.TabIndex = 4;
   this.button1.Text = "显示对话窗口";
   this.button1.Click += new System.EventHandler(this.button1_Click);
   //
   // Form1
   //
   this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
   this.BackColor = System.Drawing.SystemColors.ActiveCaption;
   this.ClientSize = new System.Drawing.Size(97, 408);
   this.Controls.Add(this.button1);
   this.Controls.Add(this.pictureBox3);
   this.Controls.Add(this.pictureBox2);
   this.Controls.Add(this.pictureBox1);
   this.Controls.Add(this.groupBox1);
   this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
   this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
   this.MaximizeBox = false;
   this.MinimizeBox = false;
   this.Name = "Form1";
   this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
   this.Text = "QQ2008";
   this.Load += new System.EventHandler(this.Form1_Load);
   this.groupBox1.ResumeLayout(false);
   this.ResumeLayout(false);

  }
  #endregion

  private void 按钮_我的好友_单击(object sender, System.EventArgs e)
  {
   陌生人 ++;
  }

  private void 按钮_陌生人_单击(object sender, System.EventArgs e)
  {
   陌生人 --;
   黑名单 ++;
  }

  private void 按钮_黑名单_单击(object sender, System.EventArgs e)
  {
   陌生人 --;
   黑名单 --;
  }

  private void groupBox1_Enter(object sender, System.EventArgs e)
  {
  
  }

  private void button1_Click(object sender, System.EventArgs e)
  {
   Form2 dg=new Form2();
   dg.Show();
  }

  private void Form1_Load(object sender, System.EventArgs e)
  {
  
  }

  /// <summary>
  /// 应用程序的主入口点。
  /// </summary>
  [STAThread]
  static void Main()
  {
   Application.Run(new Form1());
  }
 }
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值