Dragging Listview Items
How to drag Listview Item to another form with the same format of Listview.??? hElp please??
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Dragging Multiple Items From A Listview
i have some code to let users drag an item from a listview onto a treeview node, which works fine, but now i want to let them drag multiple items.
the problem is that when then select a bunch of items, then drag them to the treeview, it leaves only the last item they clicked on selected (as if they selected them, then just left-clicked one of them). is there a way to keep them all selected?
also, just out of interest, is there a way to make the drag icon include some text from each selected listview item along with an icon (like when you drag multiple files in windows explorer)?
thanks for any help
Add Items Without Dragging Them In
Hi,
I'm using VB6.0 and I'm trying to find a way to create combo and textboxes without dragging them on to the form from the toolbox.
I want to make a program to print out bills and each time the value in the combo is selected, a new combo should appear without using comboboxx.visible = true.
Thanks
Dragging Items In A Treeview Between Itself
I've got a tree view control in my application and i need to drag its children nodes between the parent nodes. I.e you can be able to change the parent node just by dragging a node from one parent node to anotehr. Is this possible to be done by native VB, or does it need some API involveD?
I've seen several applications using this functionality. Any idea how i can solve this problem?
Thanks!
Dragging Items In A Treeview In Itself (changing Locations)
I need to perform a drag-drop function on a treeview control in which the user can move items between different nodes of the tree.
I need to implement this functionality via dragand drop, so as to make it easy to interact. Is this possible? Do i need to go into detailed API or wiht native VB it is possible?
Any ideas? Thanks a lot ppl
ListView DRAGGING
How can I select multiple items by clicking and then dragging over the amount of records that are there?
thanks...
Listview - Turning Off Dragging
I'm in one of my old apps and noticed that for some reason I used a listview control when a listbox "might" have done the job. My comments aren't as good as they should be (lesson learned). Anyway, since I'm not sure why I used a listview instead of a listbox I'm not willing to replace it. I don't have the time.
So... Is there a property (that I can't find) that turns off dragging of items in the listview control?
Thanks,
Bernie
Listview Dragging Item
Hello, Jusk asking if there is a possible way to drag item in the listview??
it goes like this:
Listview populate with;
Item 1
Item 2
Item 3
When I drag Item 3 to the position of Item2, it goes like this;
Item 1
Item 3
Item 2
is this possible?? if not?? what should I do??
ListView And Turning Off Dragging
I have Listview with a number of items and I want a user to be able to select an item by clicking on it. Currently, if they click and drag then the icon and text go flying all over the window. How do you keep them from being able to click and drag on the icons messing up the entire list view but still allow them to click and select one? There are a number of related posts but noone seems to have a straightforward answer and this seems easy. Help please!
Thanks.
Create Shortcut By Dragging From Listview
Was wondering if someone could show me an example of creating a windows shortcut by dragging an item out of a listview control and say onto the desktop.
When creating the shortcut I would like to link to a specifix .exe, but use what was dragged out as part of the command line parameters.
Thanks in advance
Listview: Disabling User Dragging
Is there a way to disable the user from dragging items in a listview. My listview.view=lvwIcon and has to stay that way (e.g. I need the nice large icons)
Thanks in advance,
Listview Setting No Column Dragging
Hi all
you know how with the listview columns you can drag them?
howdo i stop this or get it to resize as soon as the user drags it so its kind of asking howto set the drag to be undraggable
Tom
Problem With ListView Control And Dragging
I'm trying to drag an item from one ListView control to another but whenever I click on any of the items the first item is selected no matter which I have clicked on. The drag outline does appear over the selected object though. The ListView control is in report view and all the other relevant code is below, can anyone suggest what I've done wrong?
Many thanks
Geoff
Setting up control:
Dim itmX As ListItem
lsvEvents.ListItems.Clear
lsvEvents.ColumnHeaders.Clear
lsvEvents.ColumnHeaders.Add , "Event", "Event", lsvEvents.Width / 2
lsvEvents.ColumnHeaders.Add , "Time", "Time", lsvEvents.Width / 2
lsvEvents.SmallIcons = imlLog
For each record in a recordset:
Set itmX = lsvEvents.ListItems.Add()
itmX.Text = !Name
itmX.Tag = !EventID
itmX.SubItems(1) = !OpenTime
Select Case !EventType
Case Is = "<Project File>"
itmX.SmallIcon = "Project"
Case Is = "<Resource File>"
itmX.SmallIcon = "Resource"
Case Is = "<Issue>"
itmX.SmallIcon = "Issue"
End Select
MouseDown:
Private Sub lstEvents_MouseDown(Button As Integer, Shift As Integer, x As
Single, y As Single)
Dim DY ' Declare variable.
DY = TextHeight("A") ' Get height of one line.
lblDrag.Move lstEvents.Left, lstEvents.Top + y - DY / 2, lstEvents.Width,
DY
lblDrag.Drag ' Drag label outline.
End Sub
Problem With ListView Control And Dragging
I'm trying to drag an item from one ListView control to another but whenever I click on any of the items the first item is selected no matter which I
have clicked on. The drag outline does appear over the selected object though. The ListView control is in report view and all the other relevant code is below, can anyone suggest what I've done wrong?
Many thanks
Geoff
Setting up control:
Dim itmX As ListItem
lsvEvents.ListItems.Clear
lsvEvents.ColumnHeaders.Clear
lsvEvents.ColumnHeaders.Add , "Event", "Event", lsvEvents.Width / 2
lsvEvents.ColumnHeaders.Add , "Time", "Time", lsvEvents.Width / 2
lsvEvents.SmallIcons = imlLog
For each record in a recordset:
Set itmX = lsvEvents.ListItems.Add()
itmX.Text = !Name
itmX.Tag = !EventID
itmX.SubItems(1) = !OpenTime
Select Case !EventType
Case Is = "<Project File>"
itmX.SmallIcon = "Project"
Case Is = "<Resource File>"
itmX.SmallIcon = "Resource"
Case Is = "<Issue>"
itmX.SmallIcon = "Issue"
End Select
MouseDown:
Private Sub lstEvents_MouseDown(Button As Integer, Shift As Integer, x As
Single, y As Single)
Dim DY ' Declare variable.
DY = TextHeight("A") ' Get height of one line.
lblDrag.Move lstEvents.Left, lstEvents.Top + y - DY / 2, lstEvents.Width,
DY
lblDrag.Drag ' Drag label outline.
End Sub
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!
Please Double Check This Dragging From ListBox To ListView Code For Me
I want to drag an item from a listbox to a listview so starting with my lisbox code:
Private DragID As Integer
Private blnAmDragging As Boolean
Code:
Private Sub lstUnalloc_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
If Button = vbLeftButton Then
DragID = lstUnalloc.ItemData(lstUnalloc.ListIndex)
End If
End Sub
Code:
Private Sub lstUnalloc_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
On Error GoTo errh
If Button = vbLeftButton Then
If lstUnalloc.ListIndex >= 0 Then
blnAmDragging = True
lstUnalloc.Drag vbBeginDrag
End If
End If
Exit Sub
errh:
errmsg "The following Exception occured : " & Err.Description & ", " & Err.Source & "", "Exception occured in frmMain.lstUnalloc_MouseMove ()"
End Sub
and now my listview:
Code:
Private Sub lvwPeople_DragOver(Source As Control, x As Single, y As Single, State As Integer)
On Error GoTo errh
If blnAmDragging = True Then
If State = vbLeave Then
Set lvwPeople.DropHighlight = Nothing
Else
Set lvwPeople.DropHighlight = lvwPeople.HitTest(x, y)
End If
End If
Exit Sub
errh:
errmsg "The following Exception occured : " & Err.Description & ", " & Err.Source & "", "Exception occured in frmMain.lstlist_DragOver()"
End Sub
Code:
Private Sub lvwPeople_DragDrop(Source As Control, x As Single, y As Single)
If Source = "lvwPeople" Then
Exit Sub
End If
Source.Drag vbEndDrag
Set lvwPeople.SelectedItem = lvwPeople.HitTest(x, y)
MsgBox lvwPeople.SelectedItem.Key
MsgBox DragID
End Sub
I just put 2 msgboxes to test. I have to write sql statements to assign the number to a person. I just need someone to check if I am doing the correct stuff for dragging and dropping.
Dragging List Items Around A List Box: Example
Since I can't post this in the code library, I thought I'd share it here. This code is pretty simple. It allows items to be reordered in a list box by dragging them around.
Put this in General Declarations
Code:
Dim item1 As String, item2 As String, listindex1 As Integer, listindex2 As Integer
Put this in for your list events.
Code:
Private Sub List1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
'When the mouse is clicked, we want to save the text at the spot
'and the index of the spot to variables
item1 = List1.List(List1.listindex)
listindex1 = List1.listindex
End Sub
Private Sub List1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
'When the mouse is released, we want to save the text and the spot
'again. Then we print the text to opposite spots in the list.
item2 = List1.List(List1.listindex)
listindex2 = List1.listindex
List1.List(listindex1) = item2
List1.List(listindex2) = item1
End Sub
Combine 2 Listview Items Into One Listview
I have 2 listviews that have a different listitems.
ex.
LV 1 LV 2
1. A 1. B
2. C 2. D
3. E 3. F
Is there a way to combine the 2 to another listview so that they all look like this with out doubles of matching items?
ex.
LV 3
1. A
2. C
3. E
4. D
5. E
6. F
Combine 2 Listview Items Into One Listview
I have 2 listviews that have a different listitems.
ex.
________________
LV 1 l LV 2 l
l l
1. A l 1. B l
2. C l 2. D l
3. E l 3. F l
_______l_________l
Is there a way to combine the 2 to another listview so that they all look like this with out doubles of matching items?
ex.
_______
LV 1 l
1. A l
2. C l
3. E l
4. D l
5. E l
6. F l
_______l
Msg All Listview Items
hi i am wanting to display a message box for each item in a listview. the code i currently have is:
Public Sub msgALL()
Dim i As Integer
For i = 0 To lstSYS.ListItems.Count - 1
MsgBox lstSYS.SelectedItem
Next i
End Sub
this only displays the first item as the code states to display the selected item. how can i make it cycle through?
thanks
Getting Listview Items
Hi!
i would like to retrieve the item text selected (by double clicking) in a listview.
How can I do?
Thanks
sonia
Listview Add Items
Hi, I have a Listview in my project and I would like to know how can I add all the text of the listview column to specific field name in my database Access. What Can I do? This is the code to add info to my Database:
Code:
Dim db As DAO.Database
Dim rs As DAO.Recordset
Set db = OpenDatabase(App.Path & "Base de DatosPros2003.mdb")
With db Set rs = .OpenRecordset("Tratamientos Pacientes")
End With
On Error Resume Next
With rs
.AddNew
!ID = Text2.Text
!Precio = txtTotalAmount.Text
!Usuario = txtCheckedBy.Text
!Codigo = txtProdCode.Text
!Tratamiento = Listview1.WHAT CODE I NEED TO ADD HERE?
!Descuento = txtDiscount.Text
!Tratamiento = txtDescription.Text
!Cantidad_Pagada = txtCash.Text
!Numero_Cheque = txtCheckNumber.Text
!Banco = txtBank.Text
.Update
.close
MsgBox "Congratulations", vbOKOnly + vbDefaultButton1, "Pro 2003"
End With
THANKS A LOT.
Same Items In Listview
Hello... I have one problem.
I fill the listview with some standard sql query.
SELECT Name FROM ...
If there are few same names, then they are all filled down.
Now, I want this:
if there are some names that they are exatcly the same I want just first one to be writed down, then the next different name and so on...
Is this possible?
Get ListView Items From Other App's
i need to get Item texts of a ListView control that we know it's hwnd from other applications.
we can easily send LVM_GETITEMTEXT message to the listview object and retrive any item. but i want to get items of a listview in another application and when i call sendmessage in this case, my program fail and close by windows. i think this is because of memory access or something like that. may other applications doesn't have access to the memory buffer of my program.
note that i can get list count (number of items) by sending LVM_GETITEMCOUNT message and it has no problem but i can't get text of items.
here is the basic code to retrive an item in vb (it works if you call it for listview controls that exists on your program and not other windows applications)
thanks
s.serp.
--------------------------- Module LVAPI.bas
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Public Const LVM_FIRST = &H1000 ' ListView messages
Public Const LVM_GETITEMCOUNT = (LVM_FIRST + 4)
Public Const LVM_GETITEMTEXTA = (LVM_FIRST + 45) 'unicode
Public Const LVM_GETITEMTEXTW = (LVM_FIRST + 115)
Public Type LVITEM
mask As Long
iItem As Long
iSubItem As Long
State As Long
stateMask As Long
pszText As Long 'String
cchTextMax As Long
iImage As Long
lParam As Long
iIndent As Long 'for IE>3
End Type
Function GetListViewText(ByVal hwnd As Long, ByVal ItemIndex As Long) As String
' Obtain the name of the specified Item of the list view
On Error Resume Next
Dim objItem As LVITEM
Dim baBuffer(320) As Byte, n As Long
With objItem
.mask = LVIF_TEXT
.iSubItem = 0
.pszText = VarPtr(baBuffer(0))
.cchTextMax = UBound(baBuffer) - 1
End With
n = SendMessage(hwnd, LVM_GETITEMTEXTA, ItemIndex - 1, objItem) ' ItemIndex-1 is because of list is zero-based index
GetListViewText = Left$(StrConv(baBuffer, vbUnicode), n) 'convert from binary byte array to a String
End Function
Function GetListViewCount(ByVal hwnd As Long) As Long
'this simply get number of items
GetListViewCount = SendMessage(hwnd, LVM_GETITEMCOUNT, 0, ByVal 0)
End Function
---------------------- Form1
Private Sub Form_Load()
With ListView1
.View = lvwReport
.ColumnHeaders.Add Text:="Name"
.ListItems.Add Text:="John"
.ListItems.Add Text:="Kharazmi"
.ListItems.Add Text:="ABCD"
.Refresh
End With
Label1.Caption = "N = " & GetListViewCount(ListView1.hwnd)
Label2.Caption = "Item 1 = " & GetListViewText(ListView1.hwnd, 1)
Label3.Caption = "Item 3 = " & GetListViewText(ListView1.hwnd, 3)
'The Problem is that we can't call this way for ListView controls of other applications!
End Sub
Need Help In ListView Items
Hi All
i use this code to add an item to listview
VB Code:
Dim itmX As ListItemSet itmX = ListView1.ListItems.Add(, , "aaaaaaa") itmX.SubItems(1) = Time itmX.SubItems(2) = Date
it add new item in the last row
how to add item in order newst item is in first row
thanx
Items In A ListView
I have a combobox which acts as a Lookup table, a command button and a ListView. My aim is that when i select an item from the combo, on clicking the command button, the selected item from the combo gets listed in the ListView. The code for filling the combo is :
VB Code:
Dim strSQL As String 'Declare the variables we need strSQL = "SELECT movieId, title FROM movieInfo" Set rsMovie = New ADODB.Recordset rsMovie.Open strSQL, cnAddMovie, adOpenForwardOnly, adLockReadOnly, adCmdText With cboTitle .Clear Do While Not rsMovie.EOF .AddItem rsMovie.Fields("title").Value .ItemData(.NewIndex) = rsMovie.Fields("movieId").Value rsMovie.MoveNext Loop End With rsMovie.Close Set rsMovie = Nothing
BUT now when the selected item is listed in the ListView, I want the following code executed.
VB Code:
'strSQL = "SELECT movieInfo.movieId, movieInfo.title, MediaType.StrKey, MediaType.DefRentPricePerDay, MediaType.DefRentPeriodInDays FROM movieInfo INNER JOIN MediaType ON movieInfo.media_catId = MediaType.media_catId WHERE movieId = " & cboTitle.ItemData(cboTitle.ListIndex)
So that in the ListView, I have columnsheaders showing Movie title, Format, rentPrice etc
How can i do that?
Listview Max Items
Can someone please tell me what is the maximum number of items in the list with Listview?
My program searches a database with thousands of records and reports errors and I would like to be able to list them on the screen so the end user can review.(Printing them out is another story) A listbox runs out at about 32k items.
I would only need 4 colums in the listview.
If anyone has any ideas on what or how I can do this , I am all ears...
Thanks in Advance
Trent
Getting Sum Of Items In Listview......
Ok, I got a response to a question similar to this before, but for some reason, I couldn't even modify the code to work, and kept getting an object required error. Maybe it had something to do with my use of the listview control Anyway, I'll be more specific this time. Here goes.
Listview2:
In the main column is text, and in subitem1 column is a number (i.e 2:30)
What I want to do is on a command1_click() get the sum of all the numbers in listview2 subitem1, and set that = to sum
Then let listview3.listitems.add SUM
Hope that makes sense. Anway since there is a ":" in the number, it must currently be formatted as a string and not an integer right? So, what do I need to do to total up all of these numbers? Any help is greatly appreciated.
Listview Items....
Hey peops, I was wondering if there was anyone out there that could tell me how to disable editing within a listview's columns...What I'm doing is connecting to an Oracle DB and pulling data and then putting that recordset data onto my listview so i can view them like a spreadsheet (obviously). The problem is that when i click on an item and hold down the mouse button long enough, I'm able to edit the first column...I want to disable this ability. Basically i want none of the recordset data to be renamed or changed, but the items can be selected...thanks in advance
Add Items To ListView?
I have the code below which puts two column headers at the top of my ListView control, (Title) and (Description). . .
Code:
Private Sub Form_Load()
Me.ListView1.View = lvwReport
Me.ListView1.ColumnHeaders.Clear
Me.ListView1.ColumnHeaders.Add , , "Title", ListView1.Width / 2
Me.ListView1.ColumnHeaders.Add , , "Description", ListView1.Width / 2
End Sub
Can anyone show me the code I can add to this that will add one item in the list view control with the text (Item Title) under the ‘Title’ column and (Item Description) under the ‘Description’ column?
.
Moving Through Items In A Listview
Am I being a complete , or what? I'm trying to move through the items in a listview, so that I can insert the entries one-by-one in to DB - ie each item in the listview represents a new record in a DB table.
Now, I would have expected (as with all things VB) this to be quite straight forward. Something along the lines:
ListView1.selecteditem.movenext
I know this a bit hopeful, but I can't believe there's no way to incrementally move through all the items.
I've been through MSDN and searched this entire forum for a similar thing but I cant find anything.
I must be missing something really obvious here!
Highlighting Items In Listview...
I have this small application that has a listview wherein it gets populated by database records. My DB table is arranged alphabetically so it will also be arranged in the listview as well. But I'm haveing trouble displaying/highlighting the last item that was entered in the table so the user will have to scroll through the whole listview to see if what they entered did go in since the table is arranged alphabetically. The display type of my listview is in lvwReport by the way. Is there anyway I can do this?
Listview Items To Excel...
I was just wondering, is it possible to export the listview items to excel? If so, would it also be possible to export the selected items only?
ListView Adding Items.
Code:
Private Sub Form_Load()
With ListView1
.ColumnHeaders.Add Text:="Server"
.ColumnHeaders.Add Text:="Ram"
.ColumnHeaders.Add Text:="CPU"
.ColumnHeaders.Add Text:="C:"
.ColumnHeaders.Add Text:="Ping"
.View = lvwReport
End With
End Sub
i have this code to give the listview1 5 diffrent columns.
can someone give me the code that when command1 is clicked, it will add a row underneath the columns in this order:
server1
ram1
cpu1
c:1
ping1
just so i know how to do this.
Swap Items In Listview
Hello I have a scenario here.
I have a Listview and two command butons (up and down)
Initial Listview Items
A text1 text1
B text2 text2
C text3 text3 - Selected
now when the Up button this is what will happen
A text1 text1
C text3 text3 - Selected
B text2 text2
Hope someone here help me.
Thanks
Adding N Items Into ListView
I am using following code to add records read from a text file into a ListView object.
Code:
Dim S
Dim SP
Dim i
Dim LItem As ListItem
i = 1
Open App.Path & "dataspdates.txt" For Input As #1
Do While Not EOF(1)
Line Input #1, S
SP = Split(S, "+", , vbTextCompare)
Set LItem = ListView1.ListItems.Add(, , SP(0))
LItem.SubItems(1) = SP(1)
i = i + 1
Loop
Close #1
My ListView Control has just two columns, and the text file contains records like:
3/10/04+Mr.D Birthday
6/1/04+Mr.C.Anniversary
In the above code, SP will store the splitted line read from the file. The problem is that the above code displays an error "Subscript out of range", at the line starting with "Set LItem".
How to keep adding records to ListView till EOF.
Listview Selected Items
hey i was wondering if it is possible to retrieve a collection of selected items from a listview which has multiselect set to true
(not checked, but selected)
i was hoping i could do something like this ...
Code:
dim li as listitem
for each li in listview1.selecteditems
' do something
next li
... but it doesn't appear to be so easy
any hints ?
thanks,
huby.
Please Help {listview Items To Textbox}
I want to add all the data from the first column to a textbox. I was thinking of this:
For i = 1 To ListView1.ListItems.Count
Text1.Text = ListView1.ListItems(i)
But this only gets the last item. So I thought how about if I have i and add 1 to it each time after putting the next item into the textbox and if there is no more data it would stop.
I don't know how to do this, can someone please help?
Navigate Through ListView Items...
I have a listview control on a form, and I want to be able to navigate through rows with Up/Down buttons, I can't figure out how this is achieved atall, I wish to do similar to "List1.ListIndex = List1.ListIndex + 1" if i was using a listbox control... But i cant find the appropriate commands for a listview control... any help would be greatly appreciated
Thanks
Matt
Adding Items To A Listview
I have searched thru the forum, just cant find what im looking for. this is the layout of my listview
Fkey | Action
I wish to add items to the fkey column, and also text to the action clolumn.
listview1.ListItems.Add.Text = "blah" <-- i tried that, but that only goes in Fkey...
How would i do this please,
Thanks
Coloring Listview Items
Could someone simplify this code:
Private Sub Command4_Click()
Dim i As Integer
1) ListView1.SelectedItem.ForeColor = vbRed
For i = 1 To 4
2) lista.ListSubItems.Item(i).ForeColor = vbRed
Next
End Sub
lista is a listview object
It does work but it seems like it should could be easier made.
I´m a little lost with all the subitems, listitems, item, selected, selecteditem etc.
1) just colors the first column in the row.
2) colors the next columns (the subitems).
so the code colors a row, and it works but it looks stupid (I think).
|