PC Review


Reply
Thread Tools Rate Thread

trying to do drag drop

 
 
active
Guest
Posts: n/a
 
      23rd Nov 2003
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.

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??

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 listbox. Is ByRef the preferred way.

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


 
Reply With Quote
 
 
 
 
One Handed Man
Guest
Posts: n/a
 
      23rd Nov 2003
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



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Drag and Drop Column headers (drag and drop using wndProc?) KamiiKoneko@gmail.com Microsoft Dot NET Framework Forms 0 17th Dec 2007 03:28 PM
Access denied trying to "md"? Drag & Drop is now drag, drop, OK, OK ???? Noozer Windows Vista Installation 0 17th Oct 2006 10:45 AM
drag and drop AND drag Marcel Microsoft Dot NET Framework Forms 0 3rd Nov 2005 09:44 PM
drag and drop AND drag SharpCoderMP Microsoft C# .NET 1 3rd Nov 2005 09:15 PM
Error trying to drag and drop between app instances (of same app) Derrick Microsoft C# .NET 1 6th Oct 2004 07:37 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:22 PM.