日期:2014-05-18  浏览次数:21236 次

C#入门一题 (很简单。)
创建一个Windows应用程序项目,项目中只有一个社会窗体,窗体上有两个按钮.其中的一个按钮被单击时应将窗体往左移动2像素,别一个按钮应将窗体往右移动2像素. 

他提示我使用Location属性的X和Y子属性. 可是我不会
有达人能帮我解决一下吗.
我用了另一个方法,好像也可以实现.代码如下 

C# code
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的X,Y属性实现. 
谢谢各位了.!

------解决方案--------------------
C# code

Location = new Point(Location.X + 2, Location.Y);