PDA

View Full Version : سوال: component



royalreihaneh
یک شنبه 22 فروردین 1389, 20:12 عصر
چه جوری می شه فرمی طراحی کرد که کنترل های اون در زمان اجرا قابلیت جا به جایی داشته با شند :متفکر:

EhsanAvr
یک شنبه 22 فروردین 1389, 22:11 عصر
سلام.ببین این به دردت میخوره.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace MoveFormControlsAtRunTime
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
int x1;
int y1;
bool xy;
private void Form1_Load(object sender, EventArgs e)
{

}

private void label1_MouseDown(object sender, MouseEventArgs e)
{
xy = true;
x1=e.X;
y1=e.Y;
}

private void label1_MouseUp(object sender, MouseEventArgs e)
{
xy = false;
}

private void label1_MouseMove(object sender, MouseEventArgs e)
{
if (xy == true)
{
if (e.Button == MouseButtons.Left)
{
label1.Left = label1.Left + e.X - x1;
label1.Top = label1.Top + e.Y - y1;
}
}
}
}
}

EhsanAvr
یک شنبه 22 فروردین 1389, 22:18 عصر
اینم ببین
http://barnamenevis.org/forum/showpost.php?p=945294&postcount=476