active wrote:
> Code below.
> Starting to use DragDrop and I get the message that the index is out
> of range when I mouse down and move a little. The box has maybe 10
> items and I'm selecting one in the middle.
Put a debug.writeline to send the co-ordinates to the output window. This
way you will see what you are trying to work with. I have found that the
screen co-ordinates sometimes need to be converted to the client
co-ordinates of the control. Using the PointToScreen co-ordinate in the
RectangleToScreen methods.
>
> Second question. In the examples for ListBox they use:
> alstFrom.SelectedItem.Text but when I add a dot after SelectedItem I
> get only the option GetType. Can this be explained??
Because you have not instantiated it as a New type of LitBoxItem. It
doesent know at pre run stage what it is. As a matter of course, use OPTION
STRICT, this will prevent late binding compilation and reduce the number of
these kinds of errors.
>
> Finally. The conversion from VB6 placed ByRef with the first
> argument. Any reason. Seems like ByVal would also work. In fact I
> think it would work even if I wanted to make changes in the lis
tbox.
> Is ByRef the preferred way.
It's up to you to use it as appropriate. If you specified ByVal on the VB6
code, it would translate it the same otherwise it will be byRef as default.
Regards OHM
>
> Thanks for any insight passed along,
> Cal
>
> Private Sub MouseMoveHelper(ByRef alstFrom As
> System.Windows.Forms.ListBox, ByVal sender As Object, ByVal e As
> System.Windows.Forms.MouseEventArgs)
> If e.Button = 0 Or alstFrom.Items.Count < 1 Or mbolDragProhibited
> Then Exit Sub
> Dim tbase As ListBox = DirectCast(sender, ListBox)
> Dim data As New DataObject
> data.SetData(DataFormats.Text, CStr(alstFrom.SelectedItem))
> Dim effect As DragDropEffects = DragDropEffects.Move
> effect = tbase.DoDragDrop(data, effect)
> End Sub
|