C#入门一题 (很简单。)
创建一个Windows应用程序项目,项目中只有一个社会窗体,窗体上有两个按钮.其中的一个按钮被单击时应将窗体往左移动2像素,别一个按钮应将窗体往右移动2像素.
他提示我使用Location属性的X和Y子属性. 可是我不会
有达人能帮我解决一下吗.
我用了另一个方法,好像也可以实现.代码如下
using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;namespace MoveForm{ public partial class frmMoveForm : Form { public frmMoveForm() { InitializeComponent(); } private void btnLeft_Click(object sender, EventArgs e) { this.Left = this.Left - 2; } private void btnRight_Click(object sender, EventArgs e) { this.Left= this.Left + 2; } }}
Location = new Point(Location.X + 2, Location.Y);