这个VB事件怎么没用呀

honghuige 2003-08-21 09:18:40
Private Sub Form_DragDrop(Source As Control, X As Single, Y As Single)
Text1.Text = "aaaaa"
End Sub

DragDrop这个事件不是拖放事件吗,,我拖到明天好像也没有触发事件呀,,,难道是我的VB有问题吗
...全文
60 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
danielinbiti 2003-08-23
  • 打赏
  • 举报
回复
Private Sub Form_DragDrop(Source As Control, X As Single, Y As Single)
Text1.Text = "aaaaa"
End Sub

Private Sub Form_Load()
Text1.DragMode = 1
End Sub
qifanghcy 2003-08-23
  • 打赏
  • 举报
回复
dragmode才两个属性,一个手工,一个自动的,你看花眼了吧???
honghuige 2003-08-23
  • 打赏
  • 举报
回复
现在明白了一些,,那大家可以讲明白一些吗,,,
手动指的是什么,,自动又指的是什么,,,,
是不是手动指的是控件在拖动过程中有一个虚框,可以引发DragDROP和DragOver事件,,,对吗,,,,,,,

那自动又是什么,,控件会自动移动吗,,,
踏平扶桑 2003-08-22
  • 打赏
  • 举报
回复
是text1的一个以m开头的属性
呵呵~~
忘了怎么拼写了,反正它只有两个值,true和false,在text1属性窗口里设置,就是vb屏幕右边中间。
踏平扶桑 2003-08-22
  • 打赏
  • 举报
回复
是text1的一个叫m开头的属性
呵呵~~
忘了怎么拼写了。反正它就有两个值,true和false,在属性窗口里设置。
honghuige 2003-08-22
  • 打赏
  • 举报
回复
怎么设置,,,是哪个属性呀
qingming81 2003-08-22
  • 打赏
  • 举报
回复
楼上的说M开头的属性,大概是指.movable属性,可是这个属性如果设置为false,则按住标题栏也拖不动。控件拖动要用到的属性是.dragmode,应设置为0。如果是窗体,不是这样用的。
qingming81 2003-08-22
  • 打赏
  • 举报
回复
DragOver Event Example
This example demonstrates one way to indicate a valid drop target. The pointer changes from the default arrow to a special icon when a TextBox control is dragged over a PictureBox control. The pointer returns to the default when the source is dragged elsewhere. To try this example, paste the code into the Declarations section of a form that contains a small TextBox and a PictureBox. Set the TextBox control's DragMode property to 1, and then press F5 and drag the TextBox over the PictureBox.

Private Sub Picture1_DragOver (Source As Control, X As Single, Y As Single, State As Integer)
Select Case State
Case vbEnter
' Load icon.
Source.DragIcon = LoadPicture("ICONS\ARROWS\POINT03.ICO")
Case vbLeave
Source.DragIcon = LoadPicture() ' Unload icon.
End Select
End Sub

Private Sub Picture1_DragDrop (Source As Control, X As Single, Y As Single)
Source.DragIcon = LoadPicture() ' Unload icon.
End Sub

qingming81 2003-08-22
  • 打赏
  • 举报
回复
什么M开头的属性?不是这样用的。看MSDN的


Visual Basic Reference

DragDrop Event


Occurs when a drag-and-drop operation is completed as a result of dragging a control over an object and releasing the mouse button or using the Drag method with its action argument set to 2 (Drop).

Syntax

Private Sub Form_DragDrop(source As Control, x As Single, y As Single)

Private Sub MDIForm_DragDrop(source As Control, x As Single, y As Single)

Private Sub object_DragDrop([index As Integer,]source As Control, x As Single, y As Single)

The DragDrop event syntax has these parts:

Part Description
object An object expression that evaluates to an object in the Applies To list.
index An integer that uniquely identifies a control if it's in a control array.
source The control being dragged. You can include properties and methods in the event procedure with this argument — for example, Source.Visible = 0.
x, y A number that specifies the current horizontal (x) and vertical (y) position of the mouse pointer within the target form or control. These coordinates are always expressed in terms of the target's coordinate system as set by the ScaleHeight, ScaleWidth, ScaleLeft, and ScaleTop properties.


Remarks

Use a DragDrop event procedure to control what happens after a drag operation is completed. For example, you can move the source control to a new location or copy a file from one location to another.

When multiple controls can potentially be used in a source argument:

Use the TypeOf keyword with the If statement to determine the type of control used with source.


Use the control's Tag property to identify a control, and then use a DragDrop event procedure.
Note Use the DragMode property and Drag method to specify the way dragging is initiated. Once dragging has been initiated, you can handle events that precede a DragDrop event with a DragOver event procedure.


--------------------------------------------------------------------------------
Send feedback to MSDN.Look here for MSDN Online resources.


DragDrop Event Example
This example demonstrates the visual effect of dropping a PictureBox control onto another PictureBox control. To try this example, paste the code into the Declarations section of a form that contains three PictureBox controls. Set the DragMode property for Picture1 and Picture2 to 1 (Automatic). Use the Picture property to assign bitmaps to Picture1 and Picture2, and then press F5 and drag Picture1 or Picture2 over Picture3.

Private Sub Picture3_DragDrop (Source As Control, X as Single, Y As Single)
If TypeOf Source Is PictureBox Then
' Set Picture3 bitmap to same as source control.
Picture3.Picture = Source.Picture
End If
End Sub

honghuige 2003-08-22
  • 打赏
  • 举报
回复
到底是哪一个M开头的属性呀,,我找不到
honghuige 2003-08-22
  • 打赏
  • 举报
回复
dragmode这个属性有十几个选项,,,,还有,,根本不能设置为零
踏平扶桑 2003-08-21
  • 打赏
  • 举报
回复
要把拖放设置为true才行.
honghuige 2003-08-21
  • 打赏
  • 举报
回复
DrogOver这个也一样

7,763

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧