Click here to Skip to main content
15,905,877 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,


I want to change my textbox position run time on page as user wants.

User can able to drag and drop this textbox anywhere on page.


how can i achieve this in .net ?


Please guide me....
Posted

you can use MouseDown and MouseUP event. In addition you can use MouseMove event with a thread/delegate to get new position of textbox

Your code will look like

int IsMouseDown = false;


Protected void MouseDownEvent(....)
{
IsMouseDown = true;
}


Protected void MouseUpEvent(....)
{
IsMouseDown = false;
}


Protected void MouseMoveEvent(....)
{
if(IsMouseDown)
{
//Call delegate to update TextBox Position
}
}



Thanks
 
Share this answer
 
use the MouseMove event and put the blow line

textBox1.Location = new Point(e.X, e.Y);
 
Share this answer
 
Comments
Alizee@CP 15-Jun-11 4:30am    
How this MouseMove sets to textbox and defined in cs?
 
Share this answer
 
Use
DragPanelExtender from Ajax control toolkit
 
Share this answer
 
Are you using Win Forms, WPF, ASP.NET? I'll assume, here, that you are using WinForms; you need to catch the mouse down, mouse move and mouse up events on the text box. Then, you just update the position of the textbox based on this.
 
Share this answer
 
Comments
Alizee@CP 15-Jun-11 3:31am    
I am using ASP.net forms
Pete O'Hanlon 15-Jun-11 4:26am    
Then you're going to have to write some Javascript to do this - the principal is the same. BTW, you really should have put that you were using ASP.NET in your description. Please try to include as much information as possible in future - we can't guess what you are doing.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900