본문 바로가기

컴퓨터/언어,프로그래밍

How to Move the Textbox Control in C#

private void button1_Click(object sender, EventArgs e)
{
    this.textBox1.Location = new System.Drawing.Point(2, 3);
}


public partial class Form1 : Form
{
    int tickX = 0;
    int tickY = 0;
    public Form1()
    {
        InitializeComponent();
    }
    private void Form1_Load(object sender, EventArgs e)
    {
        this.textBox1.Location = new System.Drawing.Point(28, 38);
    }
    private void button1_Click(object sender, EventArgs e)
    {
        textBox1.Location = new Point(0, 0);
        timer1.Enabled = true;
    }
    private void timer1_Tick(object sender, EventArgs e)
    {
        this.textBox1.Location = new System.Drawing.Point(tickX, tickY);
        tickX++;
        tickY++;
    }
}


private void Form1_MouseMove(object sender, MouseEventArgs e)
        {
if (e.X == textBox1.Location.X - 1 && (e.Y >= textBox1.Location.Y - 1 && e.Y <= textBox1.Location.Y + textBox1.Height + 1))
            {
                textBox1.SetBounds(textBox1.Location.X + 5, textBox1.Location.Y, 75, 23);
            }
            if (e.X == textBox1.Location.X + textBox1.Width + 1 && (e.Y >= textBox1.Location.Y - 1 && e.Y <= textBox1.Location.Y + textBox1.Height + 1))
            {
                textBox1.SetBounds(textBox1.Location.X - 5, textBox1.Location.Y, 75, 23);
            }
            if (e.Y == textBox1.Location.Y - 1 && (e.X >= textBox1.Location.X - 1 && e.X <= textBox1.Location.X + textBox1.Width + 1))
            {
                textBox1.SetBounds(textBox1.Location.X, textBox1.Location.Y + 5, 75, 23);
            }
            if (e.Y == textBox1.Location.Y + textBox1.Height + 1 && (e.X >= textBox1.Location.X - 1 && e.X <= textBox1.Location.X + textBox1.Width + 1))
            {
                textBox1.SetBounds(textBox1.Location.X, textBox1.Location.Y - 5, 75, 23);
            }
            if (textBox1.Location.X >= this.Width - textBox1.Width - 1)
            {
                textBox1.SetBounds(1, textBox1.Location.Y, 75, 23);
            }
            if (textBox1.Location.X <= 1)
            {
                textBox1.SetBounds(textBox1.Location.X + textBox1.Width + 1, textBox1.Location.Y, 75, 23);
            }
        }
http://www.codeproject.com/Questions/167670/How-to-Move-the-Textbox-Control-in-C 



제주삼다수, 2L,... 오뚜기 진라면 매운... 상하목장 유기농 흰... 남양 프렌치카페 카... 고려인삼유통 홍삼 ... 종근당건강 오메가3... 요이치 카링 유무선...

태그