Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




Stop Drag In Listview


I found this code


Code:

' REQUIRES THE MSGHOOK.DLL LIBRARY

Const WM_NOTIFY = &H4E
Const LVN_FIRST = -100&
Const LVN_BEGINDRAG = (LVN_FIRST - 9)

Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (dest As _
Any, source As Any, ByVal bytes As Long)

Private Type NMHDR
hwndFrom As Long
idFrom As Long
code As Long
End Type

Dim WithEvents FormHook As MsgHook

Private Sub Form_Load()
' start subclassing the current form
Set FormHook = New MsgHook
FormHook.StartSubclass Me

' fill the ListView1 control with data
' ... (omitted) ...
End Sub

' this event fires when the form is sent a message

Private Sub FormHook_BeforeMessage(uMsg As Long, wParam As Long, lParam As Long, _
retValue As Long, Cancel As Boolean)

' the ListView might be notifying something to its parent form
If uMsg = WM_NOTIFY Then
' copy the MNHDR structure pointed
' to by lParam to a local UDT
Dim nmh As NMHDR
CopyMemory nmh, ByVal lParam, Len(nmh)

' check whether the notification is from the ListView1 control
' and whether it's the beginning of a drag operation
If nmh.hwndFrom = ListView1.hWnd And nmh.code = LVN_BEGINDRAG Then
' yes, cancel this operation
retValue = 1
Cancel = True
End If
End If
End Sub




but I can't get it to work (I have a lisview on my form).

It craps out at:

Dim WithEvents FormHook As MsgHook

Any ideas?




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
MSChart - Possible To Drag Out A Box Over Chart && Return X-y Start/stop Values?
Hi. I'm working w/ MSChart in an app that plots x-y data columns as a scatterplot. I want to be able to drag out a box over the plot area and return the drag start and stop values so I can zoom in on the highlighted area. I've already got all the zoom code working (by manually entering values into 4 textboxes) but this way would be more elegant. Any way to do this?


Also, 2 other questions (low priority)......
1.) anybody know how to get rid of the border that goes right from the top of the y-axis to the border the extends vertically from the right edge of the x-axis? I'm talking about the inner border here, not the outer one.

2.) i'm setting a variable to hold the max x-axis value from the plot so the user can't specify a value beyond it. However sometimes this value (randomly) gets replaced w/ the default value of 100 (which I have turned off!). I think this is a random MS bug but am not positive.

Thank you for any suggestions.

Drag Listview, Target Is The Same Listview
Hello,

I would like to let the user set a priority on listviewitems by multiple selecting them and dragging them to the correct priority.

So.. I would like to drag and drop a multiple selection and the target is the same listview.


I hope this makes sence.


patrick.

Drag And Drop From Listview To Another Listview
Hey Guys,

I've think i've tried everything but cant get it to work. I can get it to work to a text box or a list bow but not to another Listview!!

Anyone know how to drag the contents of a listview to another listview??

b

ListView -Drag&&Drop- ListView
Does anybody have an example about how to do a Drag & Drop of items between two ListViews? Any help would be welcome. Thanks, in advance.

Stop Listview Selection
I am trying to stop the first row in a listview being selected when the form is first loaded.
I have tried using the

Code:
Listview1.SelectedItem = Nothing

in the Form_Activate and this doesn't work.
There is no other control on the form to set the focus to.

Any ideas or workarounds?

Stop Listview Flickering?
Hi folks,

I am having trouble in preventing flickering while adding items to a listview.

Please help!

Stop Listview Loading
Hi everyone!

I'm filling a listview with a lot of data. If the user gets tired, he can press a button "Cancel" which should stop the listview loading.

To do that, in the loading loop I put a flag which is continously read at every cycle, for example:

Code:
While count<MaxCount And GoOn

'fill listview
'...
count +=1
End while

' Routine for cancelling
Private sub OnBtnCancel_click (...)
    GoOn=False
end sub
 

However, while the listview is filling up, I cannot press any button because the UI is freezed. So the Cancel button is unuseful.
Usage of Listview.BeginUpdate and Listview.EndUpdate() is useless.

The only way I found to make this work is to have the listview filled by another thread... but this is of course illegal because one should have the UI thread which created the listview to handle it, and not another thread.

Does someone have an idea?

Thank you

Stop Movement Of Listview Icon
hello friends,

I add items (as Icons) and set the view to Icons. When I select and move
one of the items within the listview control, it appears to drag outside the
boundaries of the listview control and the vscroll and hscroll bars appear.
The problem is I want the items to remain aligned, not randomly spread
around. Also, this is a problem because my list view control is about 2
inches square. Can I keep the icon within the white space of the control
and can I keep everything aligned?

How To Stop The Renew Index's For Listview ?
peace be with you

i make a small project used " listview "

i add a 3 items therefore the index's will be [ 1 - 2 - 3 ]

when i remove the index "2" the index's changes like this [ 1 - 2 ]

and number [2] is the index 3 before the removed

the question is :

how to set the index's not changes ??

thanks

Stop ListView Column Header
Hi Everyone,

I am using an example from VBnet about subclassing and responding to notifications from the ListView Header.

http://vbnet.mvps.org/index.html?cod...ifications.htm

The question I am trying to figure out is this. How can I get a column header to stop resizing once it has gotten to a location to a certain location. For example, stop column 1 from resizing any smaller when pt.X = 20. I would appreciate any help.

Thanks.

Stop ListView Selection When Not Wanted
Wow... that's a tough topic. It's easier to explain than what it means in the subject.

I have a TreeView-ListView interfase. The problem I'm having is when I right-click over the ListView, e.g., show it's corresponding popupmenu, and select an option which would not open any new menu or something. E.g., change some values to variables, or change the apearance of the app. What happens is that the mouse (I don't know how to explain it) "keeps" on selection status, and would select all the items you hover the mouse over after this. Of course, this would end if you click anywhere or sth. But I want to avoid this "autoselection status". Does anybody know how to do it??

How To Stop First Colume Edit In A Listview
How do you stop first colume edit?

ListView - Stop Icons Moving
Hi,
I'm using a listview control in the Icon mode, to display a control panel for my application. The only problem is that when a user clicks an icon, when you move the mouse it moves the icon as well.

Is there any way to stop the user moving the icon?

Stop And Start A Service From A ListView
Hi

I want to be able to stop and start a service that is selected from a ListView, I've tried searching but cant find anything, does anyone have any ideas?

Thanks



LIVERPOOL FOOTBALL CLUB - 5 times Champions of Europe!! 1977, 1978, 1981, 1984, 2005

FA Cup Winners - 2006

Edited by - johneast on 3/15/2006 6:31:40 AM

Listview Drag And Drop
Hi,
i have a listview set up as a listing of files.

I have the drop function up and running so the user can drop files straight into the list but what i can get working is the drop function.

All i want to be able to do is have the user drag the selected items from the list outside the form and return the address of where the files are to be dropped as a message box.

If anyone can help or point me in the right direction it would be great,
-Dave

Listview Drag && Drop
Hello,
Can someone please point me in the direction of an example of using drag & drop within listview. I've been searching the web and keep coming up empty handed!

What I'm trying to do is something like Winamp does in it's playlist for example. I would like to be able to drag a full row of data and drop it in another row.
Thank you!

Help (drag From Listbox To Listview)
I need to drag an item from mylistbox into listview

what makes it hard for me is i need it to drop whatever text im dragging onto the cell or whatever the mouse is over when it drops


Thanks

Listview Drag N Drop
Hi anyone have any ideas how to create a drag N drop between two listviews? I keep coming up with an error with this code, the line that is red is where the error comes up:


Private Sub lstview1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim c As Long

Set lstview1.SelectedItem = lstview1.HitTest(X, Y)
c = lstview1.SelectedItem.Index
lstview1.DragIcon = images.ItemIndex(3)
lstview1.Drag vbBeginDrag

End Sub



Private Sub lstview2_DragDrop(Source As Control, X As Single, Y As Single)
Dim LI2 As ListItem, LI3 As ListItem, i As Byte
Set LI3 = lstview2.HitTest(X, Y)
If LI3 Is Nothing = False Then
Set LI2 = lstview2.ListItems.Add(LI3.Index + IIf(LI3.Index < Source.SelectedItem.Index, 0, 1), , Source.SelectedItem.Text)
Else
Set LI2 = lstview2.ListItems.Add(, , Source.SelectedItem.Text)
End If
For i = 1 To lstview2.ColumnHeaders.Count - 1
LI2.SubItems(i) = lstview2.SelectedItem.SubItems(i)
Next i
lstview2.ListItems.Remove lstview1.SelectedItem.Index
LI2.Selected = True

End Sub

Drag && Drop In Listview
Hi Everone!

I would like to know, how I can drag & drop rows IN a listview.
I've seen some examples for a listbox, but not for a listview...

Thanks a lot!

Greetz Kevin,

Listview Drag && Drog
Hi! I need help with listview Drag Item... What I would like to do is to get the source line number and the target line number when I Drop the item. pls. see image below...



I've already get the source line number, now my problem is how to get the line number of the target drop item.

ListView Drag 'n Drop
I have most of the functionality for dragging and item from a listview and setting the text in a textbox to that data. However, when I drag the the item I get a drag icon that to the user code be interpreted as dragging the whole list. Basically, instead of a small rectangle I'm getting a big one. How would I go about fixing it?


Code:
Dim strHolder As String
Private Sub ListView1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Not (ListView1.HitTest(X, Y) Is Nothing) Then
ListView1.HitTest(X, Y).Selected = True
strHolder = ListView1.SelectedItem.Text
ListView1.Drag
End If
End Sub

Private Sub Text1_DragDrop(Source As Control, X As Single, Y As Single)
If TypeOf Source Is ListView Then
Text1.Text = strHolder
End If
End Sub

Private Sub Text1_DragOver(Source As Control, X As Single, Y As Single, State As Integer)
If TypeOf Source Is ListView Then
If State = 0 Then Text1.BackColor = &HFFFFC0
If State = 1 Then Text1.BackColor = &HFFFFFF
End If
End Sub

Listview Column Drag
It appears that there is no event for Listview Column Drag/Resize, and I need to execute a function when the columns are resized. Is there a way to do this?

Help With Listview Drag And Drop
I have a listview with folders on top with files listed after them. I want the user to be able to drag and drop a file into a folder. I know this can be done with drag and drop, however is there a way to auto scroll up or down when the user drags the file that way.

Thanks

Help With Drag/drop From Listview
I have a ListView control and a number of text boxes.
When I try and drag/drop from the listview to a text box or list box
I get the error 438
'Object doesn't support this property or method'
can any one help ??

Drag And Drop On ListView
Is there a way to use a drag and drop operation on a listview control itself. For example if I wanted to move a file on a listview control to a folder in the same listview control. Can this be done?

Thanks

Listview Drag Drop
How do you drag a row in a list view box an drop it to another part of the list view so that the row is inserted between the two rows where the drop occurs.

Listview Drag And Drop
Does anyone know how I can drag and drop multiple values from one listview to another. Using the listview_OLEDragDrop event I can transfer 1 value, but it doesn't work if my source listview allows multiselect.

Drag-all In A ListView, And How To Constrain To A Box
I have multi select on, and I can select as much items as I want, but how do I drag a lot at once?

Another question (listview), How do I make it so you can only drag in the boxed area of the Listview, by default, the user can keep dragging the item and the listview just gets scroll bars.

Listview Drag And Drop
Hello there,

I have a listview with 3 columns.
I Want to drag the 3 colums to a textbox.
I use the statement CentralMemoListFrm.liMemo.SelectedItem = CentralMemoListFrm.liMemo.HitTest(X, Y) to determine which row us selected.
But this statement selects the text of the first column instead of the third.

Does anybody know how to select the text of the 3 column of the row selected?

Many thankx!!!

Drag Drop With ListView
Yeap... I missed the cDItem class. Here you have the code. Hope it helps.

ListView Drag And Drop
How can I do drag and drop with a listview?

Drag+drop Listview
How can I drag at list view item (it should show the icon I specify when it is being dragged) into a richtextbox, then have text go in the rich text box where I drag the listview item to?

Drag And Drop Within Listview
Hi,

I've been using VB6 for a while now, and I've created a couple of programs from it. I've recently started using OLE Drag and Drop to be able to do several things, and all seems well when "copying" an item within the same listview. However, I can't work out how to "move" an item within the same listview. I am able to code it to the point whereby it can detect whether I want to move or copy the item, and whilst I know what to do to copy an item, I do not know how to move an item within a list view.

I hope this makes sense, and if anyone has the answer (which is probably pretty easy), it would be much appriciated.

Tim.

Drag N Drop With ListView
I would like to drag an item from one list to another
I could use a sample and some property settings

Thanks in advance

Thom Boglino
CLC Education
Thom Boglino :)
The Computer Learning Center
727-847-6955
352-683-7255
email@removed
email@removed

*Copyright (c) confidential message. No redistribution.
This message is intended for the use of the addressee
only and may contain confidential or privileged information.
If you have received it in error please notify the sender
and destroy it. You may not use it or copy it to anyone else.

How To Drag And Drop In Listview?
Hi guys,

I'm using VB.NET.

I have a simple application. Just a form, and a ListView.

I have a procedure in the form, it read's all the files in my specificed local drive, and show the files name, size and created day. It works perfectly.

Now, I want add a drag and drop functionality in this application. For example, when I drag a file from my desktop, and drop it in the list box, it will do the following:

  - Add the file's name, size and date into the listview
  - Copy the file to my another specificed path

My problem is simple, I don't know how to do it! :)

Can anyone give me a sample code and let me figure it out, or give me some hints, advice or anything can help.

Thanks in advance :)

Andy

ListView Drag And Drop
how can i drag from a listview and drop in another control, like listbox or flexgrid

Drag Drop With A Listview
i have a listview that has to colums. i want to be able to drag an item and drop the information (from the 2 columns) to another part of the form, like a label.

can anyone help me with this????

gkc

Drag And Drop In ListView
Hi,
I am trying to drag and drop multiple items from a listview on to a treeview node which will ultimately be updated in a corresponding table in the database(just like selecting multiple files in windows explorer and copying to different nodes).My problem is I am not able to drag all the items that I select.When I drag only one Item gets selected,Could somebody help me with this problem or give me some suggestions.Any suggestions will be highly appreciated.
Thanks in Advance
Cheers,
Suvipra

Stop Item Dragging/moving In ListView
Is there any way you can stop the user from moving the item position in a listview?? I need them to stay the same as i added them first by code, with them being fixed for the user and not allowing any movement of item position!

thanks!

Stop And Start A Service Selected From A ListView
Hi

I want to be able to stop and start a service that is selected from a ListView(using XP), I've tried searching but cant find anything, does anyone have any ideas?

Thanks


Drag And Drop From Listview Onto Listbox
I need to be able to perform a drag'n'drop from a listview in report-view mode onto a listbox.

I can get the first item (I want to multiple select too) that is dropped, however I cannot do the following:

1) I want multiple, performing a For Each vfn In Data.GetData(1) doesn't work, I get can the first item by msgbox data.getdata(1)

2) The destination listbox, how can I tell what item in the listbox that the dragged objects have landed on.

Cheers!

Carl.

Listview Drag Drop To Folder
I have 2 listviews. One is a list of folders and the other is a list of files. I want to be able to drag selected files to a folder in my list of folders.

Thanks

Drag&&Drop And Multiselect In Listview
Hi,

i have a litle problem.
I have activate multiselect on my listview.
But the multiselect doesen't works. I know why.

I have the MouseDown option for the drag&drop:


Code:
Private Sub PN_ChartVersionList_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)

If Shift = vbAltMask Then
Set PN_ChartVersionList.SelectedItem = PN_ChartVersionList.HitTest(X, Y)

If Not PN_ChartVersionList.SelectedItem Is Nothing Then

PN_ChartVersionList.Drag vbBeginDrag
End If
End If

'PN_ChartVersionList.SelectedItem = Nothing
End Sub

yet i must let held down the alt key to drag and drop because otherwise the mutliselect doesen't works.

How can I resolv this problem, that i can drag&drop or multiselect the items without press any keys exept for the multiselect the (ctrl + shift) key.

sry for my english :/

Drag&&Drop Between TreeView And ListView
Hi,

How can i drag&drop items between a TreeView and a ListView?

best regards,
z3r0x

Treeview/Listview Drag And Drop
Hello.

I have 2 questions about dragging into a listview:

1)
Where can I get the code for dragging a specific node from a treeview, into a listview (I just need to add the value of the dragged node as a new record in the listview).

2)
I also look for the code for dragging a file from the desktop into a listview. There are lots of exmaples on the internet for doing this, but I need to drag a file into a listview control (and not any other control).

Thanks,
Edi.

P.S.
I use VB6 and not .NET

Drag And Drop Into Listview Crashes VB
Hi,

I have two multiselect listviews in which I have OLEDrag methods/events handling drag/drop of listitems between them. If I select all of the listitems from one listview, drag and drop into another, it will *usually* cause the VB IDE to crash with a general protection fault! I've tried everything to track this one down and now I'm at my wit's end.

The problem relates only to the OLE drag/drop since I can move the same listitems via a command button (click) procedure call and it works reliably every time.

I cannot be the only one who has experienced this, so if any one has seen this sort of behavior before, please contact me! I'm running VB6 SP6, with latest mscomctl.ocx (6.1.97.86)

Much thanks,
PJ

Listview (Report) Row Drag && Drop
Hi,

I have a listview on a form which has items in it, what I would like to do is enable the user to drag & drop (manual sort) a row within the listview.

The list view is in report mode.

The following is what i have so far, but it only removes the row to the end of the list, how do I reference the index after drop to insert the row I am moving?

[[ code ]]

Private Sub Form_Load()
Dim Li As ListItem

ListView1.ColumnHeaders.Add , , "1"

Set Li = ListView1.ListItems.Add(, , "hello")
Set Li = ListView1.ListItems.Add(, , "hello2")
Set Li = ListView1.ListItems.Add(, , "hello3")
Set Li = ListView1.ListItems.Add(, , "hello4")
Set Li = ListView1.ListItems.Add(, , "hello5")
Set Li = ListView1.ListItems.Add(, , "hello6")

End Sub

Private Sub ListView1_MouseDown(Button As Integer, Shift As Integer, _
x As Single, y As Single)
Dim c As Long
Set ListView1.SelectedItem = ListView1.HitTest(x, y)
c = ListView1.SelectedItem.Index
ListView1.DragIcon = LoadPicture("C: est.ico")
ListView1.Drag vbBeginDrag
End Sub

Private Sub ListView1_DragDrop(Source As Control, x As Single, _
y As Single)
Dim li2 As ListItem
Set li2 = ListView1.ListItems.Add(, , Source.SelectedItem.Text)
ListView1.ListItems.Remove ListView1.SelectedItem.Index
End Sub

[[End Code]]

Basically I am trying to move one entire row with a listview. Thanks alot for any help provided, I have been pulling my hair out on this one!

Rgds,
Dan

Drag-drop Listview Items?
How can i ...(The Title)

Copyright © 2005-08 www.BigResource.com, All rights reserved