Microsoft KB Archive/181891

= BUG: OLE Drag Disabled When ListBox Has Multiple Columns =

Article ID: 181891

Article Last Modified on 11/18/2003

-

APPLIES TO


 * Microsoft Visual Basic 5.0 Learning Edition
 * Microsoft Visual Basic 5.0 Professional Edition
 * Microsoft Visual Basic 5.0 Enterprise Edition

-



This article was previously published under Q181891



SYMPTOMS
A listbox control is set to more than one column and the OLEDragMode property is set to Automatic to allow for OLE Drag-and-Drop. When you attempt to drag an item to another control from any column of the listbox other than the first, the item is not copied to the target control as expected.



RESOLUTION
To work around this problem, initiate the drag from the listbox using the OLEDrag method.

For example, you would add code such as the following to the MouseDown event of the "multi-column" listbox: Private Sub List1_MouseDown(Button As Integer, Shift As Integer, _                               X As Single, Y As Single) List1.OLEDrag End Sub



STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. We are researching this bug and will post new information here in the Microsoft Knowledge Base as it becomes available.



Steps to Reproduce Behavior
 Start a new Standard EXE project in Visual Basic. Form1 is created by default.  Add the following controls to Form1 and set the following properties for the appropriate controls:   Control           Default Name     Property            Setting ---  Text Box          Text1            Text                 OLEDropMode        2 - Automatic

List Box         List1            Columns             2 OLEDragMode        1 - Automatic   Copy the following code to the Module of Form1: Option Explicit

Private Sub Form_Load Dim intCounter As Integer ' Add some test data to the ListBox For intCounter = 1 To 100 List1.AddItem CStr(intCounter) Next End Sub

Private Sub List1_MouseDown(Button As Integer, Shift As Integer, _                                 X As Single, Y As Single) ' Uncomment the next line for a simple workaround. 'List1.OLEDrag End Sub  On the Run menu, click Start or press the F5 key to start the program. Select an item from the first column and drag that item to the text box.

NOTE: You must Click and release to select the item, then Click-and- Drag the same item as a second operation. Now, select an item from the second column and drag that item to the text box.

RESULT: The item from the first column is copied to the text box, but the item from the second column is not. Choose End from the Run Menu or Click the End button to stop the program. Uncomment the workaround line and repeat step 4.

RESULT: Both items are now successfully copied to the text box. Also, it no longer requires a Click to select and a second Click-and-Drag to move the item. This can now be a single Click-and-Drag operation.</li></ol>

Keywords: kbbug kbpending KB181891

-

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

© Microsoft Corporation. All rights reserved.