移动控件 [英] moving controls

查看:51
本文介绍了移动控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在运行时将多个文本框拖放到放置在窗体上的框架.
我一次只能拖放一个控件.但我希望多个控件必须一次拖放

这是代码iam用于移动单个控件的代码

I want to drag and drop multiple textboxes at runtime to a frame which is placed on form.
i am move drag or drop only one control at a time. but i want that multiple controls has to drag and drop at a time

this is code iam using for moving single controls

Dim cordinates As Point
   Dim i As Integer
   Dim cbCount As Integer
   Private Sub Control_MouseDown(ByVal sender As Object, ByVal e As MouseEventArgs) 'Handles Button1.MouseDown
       cordinates = New Point(-e.X, -e.Y)  'Holds controls X Y Coordinates while mouse is down
   End Sub
   Private Sub Control_MouseMove(ByVal sender As Object, ByVal e As MouseEventArgs) ' Handles Button1.MouseMove

       If e.Button = Windows.Forms.MouseButtons.Left Then
           Dim ControlPosition As Point = Me.PointToClient(MousePosition)
           ControlPosition.Offset(cordinates.X, cordinates.Y)
           sender.Location = ControlPosition
       End If
   End Sub

推荐答案

您必须编写一个支持此操作的容器控件.您可以将每个选定的控件添加到集合中,将该集合视为单个控件,然后将其移动.
You''d have to write a container control that supports doing this. You''d add each selected control to a collection, treating the collection as a single control, then move the collection around.


这篇关于移动控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆