hi
how can i move the usercontrol on the form?
i search about this but i find any good idea
thx in advance
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
Kirtan PatelRank #292 · 8.6K reputationPosted Dec 13, 2009, 1:45 AM EST
you can move any Control using its Location Property .
see below code
private void button1_Click(object sender, EventArgs e)
{
int x = userControl11.Location.X;
int y=userControl11.Location.Y;
userControl11.Location = new Point( x+10,y+10);
}
if my answer helps you then check "do you like this answer "check box pleasE :)
Hiren SoniRank #694 · 3.5K reputationPosted Dec 13, 2009, 2:02 AM EST
Bahar Jalali165 reputationPosted Dec 13, 2009, 2:52 AM EST
i want move user control with mouse ...
now how can i do that?
Kirtan PatelRank #292 · 8.6K reputationPosted Dec 13, 2009, 4:37 AM EST
here i Coded the code for it Just Pick the Control and Move Mouse it will move With Mouse Pointerr
check "Do you like this answer" check box if it helps you :)
bool isMouseDown =false ;
private void userControl11_MouseDown(object sender, MouseEventArgs e)
{
isMouseDown = true;
}
private void userControl11_MouseMove(object sender, MouseEventArgs e)
{
if (isMouseDown == true)
{
userControl11.Location = new Point(e.X, e.Y);
}
}
private void userControl11_MouseUp(object sender, MouseEventArgs e)
{
isMouseDown = false;
}
Hiren SoniRank #694 · 3.5K reputationPosted Dec 13, 2009, 5:03 AM EST
Hiren SoniRank #694 · 3.5K reputationPosted Dec 13, 2009, 5:05 AM EST
Bahar Jalali165 reputationPosted Dec 14, 2009, 9:36 AM EST
thanks but i do all of that works but the usercontrol don't free mouse pointer,,,, always that move with mouse and in mouse up that don't free from mouse pointer
why ??????
and in start , when program run at first, usercontrol move with mouse too, and it seems that usercontrol_mousedown and usercontrol_mouseup don't work and user control every time move with mouse ...
u can test it ... please tell me if that works fine on your computer .
Hiren SoniRank #694 · 3.5K reputationPosted Dec 14, 2009, 1:27 PM EST
Bahar Jalali165 reputationPosted Dec 15, 2009, 7:37 AM EST
i don't know what is the problem!!!!!
because when i test every which of theses solutions , any time i get true result
every time the user control don't move currect or don't free the mouse pointer
i has a request of you my good friends
please create a simple project and paste your solutions and test it and upload that for me
really i'm confiused.... why that don't work for me
thanks alot