Microsoft KB Archive/298798

= BUG: RichTextBox Drag-and-Drop With Left Mouse Button Does Not Work on Windows 2000 =

Article ID: 298798

Article Last Modified on 5/12/2003

-

APPLIES TO


 * Microsoft Visual Basic 6.0 Professional Edition, when used with:
 * Microsoft Windows 2000 Standard Edition
 * Microsoft Visual Basic 6.0 Learning Edition, when used with:
 * Microsoft Windows 2000 Standard Edition
 * Microsoft Visual Basic 6.0 Enterprise Edition, when used with:
 * Microsoft Windows 2000 Standard Edition

-



This article was previously published under Q298798



SYMPTOMS
When you are using a Windows 2000 system and you try to drag text from a RichTextBox control to another control, the icon changes, indicating that the drag-and-drop procedure is invalid for the control. This only occurs when you use the left mouse button for the drag-and-drop procedure.



RESOLUTION
To work around this problem, do either of the following:
 * Use the right mouse button when you perform a drag-and-drop procedure.
 * Set the DragMode property of the RichTextBox control to Automatic, so that you can perform a drag-and-drop procedure by using either the left or right mouse button. Note that when you use the Automatic setting you cannot select a portion of the text by using the mouse, but you can select text by using the keyboard.



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.



Steps to Reproduce Behavior
 In Visual Basic 6.0, create a new Standard EXE project. Form1 is created by default. Add a TextBox control and a RichTextBox control to Form1.  Add the following code to the code window of Form1: Private Sub Text1_DragDrop(Source As Control, x As Single, y As Single) ' Text1.Text = Source.Text     ' All text Text1.Text = Source.SelText  ' Selected (highlighted) text End Sub

Private Sub RichTextBox1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single) If RichTextBox1.SelLength > 0 Then RichTextBox1.Drag RichTextBox1.DragIcon = Me.Icon End If End Sub  Run the program. Select some text in the RichTextBox control and try to drag that text to the TextBox control by using the left mouse button. Note that when the mouse pointer is over the TextBox control the icon changes, indicating that this procedure is not valid for this control. When you release the mouse button, the text does not appear in the TextBox control. Repeat the previous step, but this time use the right mouse button to perform the drag-and-drop procedure. Note that the operation works as expected.</li> Stop the project.</li> Click the RichTextBox control. In the Properties window, change DragMode to 1 - vbAutomatic.</li> Run the program and repeat the previous steps, but use the keyboard to select text. To do this, hold down the SHIFT key while you press the arrow keys. Note that the operation works as expected whether you use the left or right mouse button.</li></ol>

Additional query words: draganddrop

Keywords: kbbug kbcodesnippet kbctrl kbdragdrop kbpending KB298798

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.