zoukankan      html  css  js  c++  java
  • 控件移动

    功能:点击按钮,按钮的位置进行移动。

    添加2个按钮:change,changeBack。

     1 using System;
     2 using System.Collections.Generic;
     3 using System.ComponentModel;
     4 using System.Data;
     5 using System.Drawing;
     6 using System.Linq;
     7 using System.Text;
     8 using System.Windows.Forms;
     9 
    10 namespace changeLocation
    11 {
    12     public partial class changeLocation : Form
    13     {
    14         public int X1 = 200;
    15         public int Y1 = 10;
    16         public int X2 = 200;
    17         public int Y2 = 110;
    18         public changeLocation()
    19         {
    20             InitializeComponent();
    21         }
    22         //换位按钮单击事件
    23         private void change_Click(object sender, EventArgs e)
    24         {
    25             change.Left = X1; change.Top = Y1;
    26             changeBack.Left = X1+100; changeBack.Top = Y1;
    27         }
    28         //反换位按钮单击事件
    29         private void changeBack_Click(object sender, EventArgs e)
    30         {
    31             change.Left = X1; change.Top = Y1;
    32             changeBack.Left = X2; changeBack.Top = Y2;
    33         }
    34         //窗体装载事件
    35         private void changeLocation_Load(object sender, EventArgs e)
    36         {
    37             change.Left = X1; change.Top = Y1;
    38             changeBack.Left = X2; changeBack.Top = Y2;
    39         }
    40     }
    41 }

    这是个很简单的程序,想了解代码控制控件移动的新手们可以拿来练练手。

  • 相关阅读:
    Pandas 基础(8)
    Pandas 基础(7)
    Pandas 基础(6)
    Pandas 基础(5)
    Pandas 基础(4)
    python matplotlib 图表局部放大
    python 带小数点时间格式化
    emacs elpy代码补全功能
    spacemacs 初始安装报错
    视频加载logo 2
  • 原文地址:https://www.cnblogs.com/Failbs/p/4103451.html
Copyright © 2011-2022 走看看