If I understood you want an animated effect when the element is moved, I found this answer https://stackoverflow.com/a/6103677/1518921
Create/declare the following class:
using System;
using System.ComponentModel;
using System.Windows.Forms;
using System.Runtime.InteropServices;
public static class Util {
public enum Effect { Roll, Slide, Center, Blend }
public static void Animate(Control ctl, Effect effect, int msec, int angle) {
int flags = effmap[(int)effect];
if (ctl.Visible) { flags |= 0x10000; angle += 180; }
else {
if (ctl.TopLevelControl == ctl) flags |= 0x20000;
else if (effect == Effect.Blend) throw new ArgumentException();
}
flags |= dirmap[(angle % 360) / 45];
bool ok = AnimateWindow(ctl.Handle, msec, flags);
if (!ok) throw new Exception("Animation failed");
ctl.Visible = !ctl.Visible;
}
private static int[] dirmap = { 1, 5, 4, 6, 2, 10, 8, 9 };
private static int[] effmap = { 0, 0x40000, 0x10, 0x80000 };
[DllImport("user32.dll")]
private static extern bool AnimateWindow(IntPtr handle, int msec, int flags);
}
And to use it do something like:
private void button2_Click(object sender, EventArgs e) {
Util.Animate(form1, Util.Effect.Slide, 150, 180);
}
Hello Pedro. Your question is a bit confusing. Could you explain better what you want? If possible by adding an example or the code you already have?
– Randrade
@Randrade I want to know how I can get the form to move itself on the screen. I’ve already got this but it doesn’t give Location. X = 1000; Location. Y = 1000;
– Pedro
You want an animated effect?
– Guilherme Nascimento
@Guilhermenascimento yes I want to put the form moved on the screen
– Pedro