473,396 Members | 2,085 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

trying to do drag drop

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
Nov 20 '05 #1
1 1305
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

Nov 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: hemant_mishal | last post by:
Hi All, I am writting a java script library which will provide inter frame drag and drop operation. The more precise will be OLE drag and drop, which means only data will be transfered from frame...
2
by: SamSpade | last post by:
There seems to be two ways to put things on the clipboard ( I don't mean different formats): SetClipboardData and OleSetClipboard If I want to get data off the clipboard do I care how it was put...
3
by: Ajay Krishnan Thampi | last post by:
I have a slight problem implementing 'drag and drop' from a datagrid to a tree-view. I have pasted my code below. Someone please advice me on what to do...pretty blur right now. ==code== ...
6
by: jojobar | last post by:
Hello, I look at the asp.net 2.0 web parts tutorial on the asp.net web site. I tried to run it under firefox browser but it did not run. If I want to use this feature in a commercial product...
3
by: VB Programmer | last post by:
In VB.NET 2005 (winform) any sample code to drag & drop items between 2 listboxes? Thanks!
6
by: Dave | last post by:
I am trying to implement drag and drop in a C# app, but for some reason I can't get it to call the GiveFeedback event. I have done everything by the book as far as I can tell, but a breakpoint in...
1
by: Darren | last post by:
I'm trying to create a file using drag and drop. I want to be able to select a listview item drag it to the shell and create a file. Each icon in the listview represents a blob in a database. When...
8
by: benkial | last post by:
I am writing a small GUI tool in C#, and I want to experiment some fancy trick as follows: when the user click on a "OK" button, the code will initiate a "Drag and Drop" operation in the GUI itself...
2
by: Robert Zahm | last post by:
I have created a C# user control which display certain filesystem information, and allows the user to drag an drop files into and out of the control. I then placed this user form in IE using an...
0
by: RHSFSS | last post by:
Hi, I have a Drag and Drop registration problem (See http://www.thescripts.com/forum/thread434707.html for similar problem post), can anyone out thereadvise on the best solution? I have a .NET 2.0 ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.