Multiple Select Items In Listview
im having a problem in listview. ther ar 2 listviews for Excel and server. the user will select fields in th excel lisview he want to upload in server lisview. it upload a field if the user only select 1 field. but if it highlights many fields it only copy the lastselected fields the other fields highlighted dont work. heres my code:
j = LVExcel.ListItems.Count For i = j To 1 Step -1 If LVExcel.ListItems(i).Selected = True And LVDatabase.ListItems(i).Selected = True Then Set rs1 = New ADODB.Recordset destinationtble = "select * from [user]" rs1.Open destinationtble, gcn, adOpenKeyset, adLockOptimistic Do While Not RS.EOF rs1.AddNew rs1.Fields(LVDatabase.SelectedItem.Text) = RS.Fields(LVExcel.SelectedItem.Text) rs1.Update RS.MoveNext Loop Set RS = Nothing End If next i
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
How To Select Multiple Items From A List Box To Another?
Hi guys..
I'd like to know how to select multiple items from a main list box to another list box? I've enabled the select extended on the main list box? Also, how do i remove multiple?
Currently, I can only move one item at a time.
Thanks!!
Regards
Vivien
Select Multiple Items In List Box
hi i got a listbox property , and i want it when i run the program , i can select multiple item in that listbox, however its wrong because it said cannot assign to read only property, --> listbox.multiselect = true is there anything code wrong? do you have solution how to fix this error so i can select multiple items in list box
thanks
Select Multiple Items In ListBox!
A VB6 Form has 2 ListBoxes which are populated from 2 different text files. Some of the items in the 2 ListBoxes are the same i.e. such items exist in both the ListBoxes. Note that the MultiSelect property of both the ListBoxes are set to 2 - Extended. The 2 ListBoxes are named List1 & List2.
When an item is selected in List1, I want that item, if it exists in List2, to get selected automatically in List2. This is how I have done it (Thanks to Hack for his input):
VB Code:
Private Sub List1_Click() Dim strItem As String Dim i As Long Dim j As Long strItem = List1.List(List1.ListIndex) For i = 0 To List2.ListCount - 1 If List2.List(i) = strItem Then List2.Selected(i) = True Exit For Else For j = 0 To List2.ListCount - 1 List2.Selected(j) = False Next End If NextEnd Sub
The problem is when more than 1 item is selected in List1. When I select Item1 in List1 & assuming that Item1 exists in List2 as well, then Item1 gets selected in List2 - till this point, no problem but keeping Item1 selected in List1, when I next select Item2 in List1 & assuming that Item2 exists in List2, then Item2 does get selected in List2 but Item1 in List2 gets de-selected whereas I want that since both Item1 & Item2 are selected in List1, both these items should automatically get selected in List2 as well. If either Item1 or Item2 (or both) are de-selected in List1, then these 2 items in List2 should also get de-selected accordingly.
In other words, what I want is when items are selected/de-selected in List1, if those items exist in List2, then those items should automatically get selected/de-selected accordingly.
What changes are needed in the above code to implement this?
VB6 Select Multiple Items From A Grid
I am using VB6 and I wanted to know how can I select multiple items and store selected/highlighted items into an array or something from a Grid? What kind of Grid do you think I should be using? Right now I am trying it out with MSHFlexGrid, but I cant figure out how to iterate through highlighted items.
Thanks
PJOFNJ
Edited by - pjofnj on 1/24/2005 9:14:13 AM
How To Select Multiple Items In A List Box
suppose i have a list box. now after selecting multiple items by pressing ctrl button and the items , now i want to store these values in array of strings, then i have to display those values using array. is it possible .pls help me.
thank you.
How To Select Multiple Items In A List Box Concurrently ?
Good day !
Let say I have a list box contains the following elements :
10
10
10
20
30
40
50
50
How can I program the code, to make it select all the items with 10 automatically when I click on any one of the element with 10 ?
I spend whole day thinking of it, but still cannot find any solution.
Help !
Thanks a lot !
SonicWave
How To Select Items In Multiple List Box Concurrently ?
Good day !
I just have a small problem here.
Let say I have 2 List Box in a form, each contain the same amount of items.
If I select an item in List Box #1 , how can I make it automatically select thehe item in the same row in List Box #2 ?
Is there any built-in properties that I can use ? or I have to program it manually ?
Thanks a lot !
Sonic Wave
Selecting/De-select All Items In A ListView
On my form that has the ListView control, I have two command buttons, cmdAll and cmdNone. When you click on cmdAll it should check all the items in the Listview and when you click on cmdNone, it should de-select all checked items. how can I ensure that? My present code for checking items is:
VB Code:
Dim i As Long For i = 1 To ListView1.ListItems.Count If ListView1.ListItems.Item(i).Checked = True Then frmMovie.lstAudio.AddItem ListView1.ListItems.Item(i).Text End IfNext
Thanks
ListView; Select/unselect Items; HideSelection
I would like to create a listview with selection disabled and no item selected.
First I thought the only thing I have to do, is to set the HideSelection property to true. But this seems not to be enough. The listview comes up with the first item selected and it is still possible to select items. Does anyone know what's missing?
Then my idea was to 'unselect' the first item to get a clear list (no items selected). I have set the 'selected' property of ListView1.SelectedItem to false. This has cleared the color of the item, but the item remains framed by a thin dotted line (focused?). How can I clear this frame?
Add Items To A Listview Multiple Columns
Hi... I have a listview with 3 columns... how can i add items to the second and the third column? i know it's a stupid question but i can't solve it
Thanks in advance
simons
Moving Multiple Listview Items Up Or Down At Once
Hi, does anybody know how to move multiple selected listview items up or down at once?
I found the subs below, but they only move one item up or down, even if I have selected multiple items.
Thanks.
vb Code:
Private Enum menmDirections MoveUp = 1 MoveDown = 2End Enum Private Sub MoveItem(ByVal penmDirection As menmDirections)Dim lvwItem As ListItemDim lvwNew As ListItemDim lvwSubItem As ListSubItemDim lngIndex As Long Set lvwItem = lstView.SelectedItem If Not (lvwItem Is Nothing) Then If penmDirection = MoveUp Then lngIndex = lvwItem.Index + 2 ElseIf penmDirection = MoveDown Then lngIndex = lvwItem.Index - 1 End If If lngIndex > 0 And lngIndex <= lstView.ListItems.Count + 1 Then Set lvwNew = lstView.ListItems.Add(lngIndex, , lvwItem.Text) For Each lvwSubItem In lvwItem.ListSubItems lvwNew.ListSubItems.Add , lvwSubItem.Key, lvwSubItem.Text, lvwSubItem.ReportIcon, lvwSubItem.ToolTipText Next lvwSubItem lvwNew.Selected = True Set lvwNew = Nothing lstView.ListItems.Remove lvwItem.Index End If Set lvwItem = Nothing End IfEnd Sub
vb Code:
Private Sub MoveUp(lv As ListView) Dim itm As ListItem, itmNew As ListItem, i As Long If lv.SelectedItem.Index > 1 Then Set itm = lv.SelectedItem Set itmNew = lv.ListItems.Add(itm.Index - 1, , itm.Text, itm.Icon, itm.SmallIcon) For i = 1 To itm.ListSubItems.Count With itm.ListSubItems(i) Call itmNew.ListSubItems.Add(, .Key, .Text, .ReportIcon, .ToolTipText) End With Next lv.ListItems.Remove itm.Index itmNew.Selected = True lv.SetFocus End IfEnd Sub Private Sub MoveDown(lv As ListView) Dim itm As ListItem, itmNew As ListItem, i As Long If lv.SelectedItem.Index < lv.ListItems.Count Then Set itm = lv.SelectedItem Set itmNew = lv.ListItems.Add(itm.Index + 2, , itm.Text, itm.Icon, itm.SmallIcon) For i = 1 To itm.ListSubItems.Count With itm.ListSubItems(i) Call itmNew.ListSubItems.Add(, .Key, .Text, .ReportIcon, .ToolTipText) End With Next lv.ListItems.Remove itm.Index itmNew.Selected = True lv.SetFocus End IfEnd Sub
Listview - DragDrop Multiple Items
I have the following code that successfully will drag & drop one item at a time, but doesn't work all the time if multiple rows are selected?
When I start to drag, sometimes nothing happens.
Anybody point me in the right direction please?
Code:
Private Sub lvwSelected_OLEDragDrop(Data As MSComctlLib.DataObject, Effect As Long, Button As Integer, Shift As Integer, x As Single, y As Single)
On Error GoTo ErrTrap
Dim i As Long
Dim lvwItem As ListItem
For i = 1 To lvwSource.ListItems.Count
If lvwSource.ListItems(i).Selected = True Then
Set lvwItem = lvwSelected.ListItems.Add(, , lvwSource.ListItems(i).Text)
lvwItem.SubItems(1) = lvwSource.ListItems(i).SubItems(1)
lvwItem.SubItems(2) = lvwSource.ListItems(i).SubItems(2)
'remove original item
lvwSource.ListItems.Remove i
End If
Next
Also, when dragging multiple items across, and removing the original item, I now get an error because the ListItem.Count is now out of bounds.
How would I handle this?
Would I add 1 to the value of 'i' before the next loop?
Multiple Selected Items In A Listview
Hello, how can I find out how many selected items there are in a listview?
I'm showing a popup menu when the user right-clicks on an item, but I need to know if only 1 item is selected, so I can disable a menu option.
I've tried this, but it doesn't work.
VB Code:
If ListView.SelectedItem < 2 Then mnuCopyMultiple.Enabled = False
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
Remove Multiple Items From ListView
I've got a ListView control with the MultiSelect property set to True and would like to remove all of the selected items only. I've looked at some of the threads concerning this issue but am still having trouble. I can remove a single selected item but not all of the selected items. My code is as follows:
Code:
Private Sub cmdRemove_Click()
Dim I As Integer
For I = 1 To lstPlot.ListItems.Count
If lstPlot.ListItems(I).Selected = True Then
lstPlot.ListItems.Remove (I)
End If
Next I
End Sub
What am I missing?
Thanks for your help!
Please Help Me With Drag-n-Drop Of Multiple Items From One Listview To Another.
Hello!
I'm facing a problem with Listview Drog and Drop of multiple items from one listview to another listview. When I try to Drag only one single item, the item is dragged without any problem. However, when the multiple selected items are dragged, the Listview on which the items are dropped, receives information about only one item and not all selected items. The item, about which the information is received, is the same on which I click and hold mouse to start drag action. So, it looks like even though multiple items are selected in a listview, while executing the Drag-Drop action, listview treats it as single item selected!
Is this a default behavior of Listview or am I missing/doing anything wrong? Any work-around for this (seems like default) behavior of Listview? I searched for it and got a code example at http://btmtz.mvps.org/listview/ where the author has demonstrated Drag-Drop of multiple items. However, the code is specifically restricted to re-arranging items within same Listview and the information is transported via Drag-Drop to another Listview, upon which the items are dropped.
To help you all to get a better insight of my problem, I have attached a Demo of Listview Drag-n-Drop. Please see the project and you will see that when one item is dragged from left side Listview to right side Listview, no problem for VB to allow me to do it! However, when you select multiple items in left side Listview and try dragging those to right side Listview, only one item is dragged. Please let me know if I'm doing anything wrong here and please help me to get this stuff to work!
Waiting for your valuable reply ...
Regards,
Ruturaj.
Show Multiple Items In Listview Taken From Database
How would I show multiple items from an Access database in a listview?
Example: Let's say my database looks like this:
Sender Subject Date
me@isp.com Some Subject 1-13-00 7:59AM
you@otherisp.com Some other subject 7-30-01 8:00AM
I want to load both items into a listview. My current procedure only loads one item at a time. Here is the procedure:
Code:
Dim Recordset As ADODB.Recordset
Select Case Node.Text
Case "Trash"
If Recordset.EOF = True Then Exit Sub
lvwMail.ListItems.Clear
With lvwMail.ListItems.Add(, , Recordset!Sender)
.SubItems(1) = Recordset!Subject
.SubItems(2) = Recordset!Date
End With
End Select
Please Help Me With Drag-n-Drop Of Multiple Items From One Listview To Another.
Hello!
I'm facing a problem with Listview Drog and Drop of multiple items from one listview to another listview. When I try to Drag only one single item, the item is dragged without any problem. However, when the multiple selected items are dragged, the Listview on which the items are dropped, receives information about only one item and not all selected items. The item, about which the information is received, is the same on which I click and hold mouse to start drag action. So, it looks like even though multiple items are selected in a listview, while executing the Drag-Drop action, listview treats it as single item selected!
Is this a default behavior of Listview or am I missing/doing anything wrong? Any work-around for this (seems like default) behavior of Listview? I searched for it and got a code example at http://btmtz.mvps.org/listview/ where the author has demonstrated Drag-Drop of multiple items. However, the code is specifically restricted to re-arranging items within same Listview and the information is transported via Drag-Drop to another Listview, upon which the items are dropped.
To help you all to get a better insight of my problem, I have attached a Demo of Listview Drag-n-Drop. Please see the project and you will see that when one item is dragged from left side Listview to right side Listview, no problem for VB to allow me to do it! However, when you select multiple items in left side Listview and try dragging those to right side Listview, only one item is dragged. Please let me know if I'm doing anything wrong here and please help me to get this stuff to work!
Waiting for your valuable reply ...
Regards,
Ruturaj.
Please Help Me With Drag-n-Drop Of Multiple Items From One Listview To Another.
Hello!
I'm facing a problem with Listview Drog and Drop of multiple items from one listview to another listview. When I try to Drag only one single item, the item is dragged without any problem. However, when the multiple selected items are dragged, the Listview on which the items are dropped, receives information about only one item and not all selected items. The item, about which the information is received, is the same on which I click and hold mouse to start drag action. So, it looks like even though multiple items are selected in a listview, while executing the Drag-Drop action, listview treats it as single item selected!
Is this a default behavior of Listview or am I missing/doing anything wrong? Any work-around for this (seems like default) behavior of Listview? I searched for it and got a code example at http://btmtz.mvps.org/listview/ where the author has demonstrated Drag-Drop of multiple items. However, the code is specifically restricted to re-arranging items within same Listview and the information is transported via Drag-Drop to another Listview, upon which the items are dropped.
To help you all to get a better insight of my problem, I have attached a Demo of Listview Drag-n-Drop. Please see the project and you will see that when one item is dragged from left side Listview to right side Listview, no problem for VB to allow me to do it! However, when you select multiple items in left side Listview and try dragging those to right side Listview, only one item is dragged. Please let me know if I'm doing anything wrong here and please help me to get this stuff to work!
Waiting for your valuable reply ...
Regards,
Ruturaj.
Please Help Me With Drag-n-Drop Of Multiple Items From One Listview To Another.
Hello!
I'm facing a problem with Listview Drog and Drop of multiple items from one listview to another listview. When I try to Drag only one single item, the item is dragged without any problem. However, when the multiple selected items are dragged, the Listview on which the items are dropped, receives information about only one item and not all selected items. The item, about which the information is received, is the same on which I click and hold mouse to start drag action. So, it looks like even though multiple items are selected in a listview, while executing the Drag-Drop action, listview treats it as single item selected!
Is this a default behavior of Listview or am I missing/doing anything wrong? Any work-around for this (seems like default) behavior of Listview? I searched for it and got a code example at http://btmtz.mvps.org/listview/ where the author has demonstrated Drag-Drop of multiple items. However, the code is specifically restricted to re-arranging items within same Listview and the information is transported via Drag-Drop to another Listview, upon which the items are dropped.
To help you all to get a better insight of my problem, I have attached a Demo of Listview Drag-n-Drop. Please see the project and you will see that when one item is dragged from left side Listview to right side Listview, no problem for VB to allow me to do it! However, when you select multiple items in left side Listview and try dragging those to right side Listview, only one item is dragged. Please let me know if I'm doing anything wrong here and please help me to get this stuff to work!
Waiting for your valuable reply ...
Regards,
Ruturaj.
Multiple Select In Listview
I'm trying to figure out how to tell what records are selected in a listview when the user clicks a button. Lets say the user uses the shift key to select the first 5 records. How can I tell what records are selected when he clicks the button? If I look at the selectedItem it only gives me the last one selected. Thanks for the help.
ListView Multiple Select
How do I get the text of all the items that are selected in a listview?
For i = 1 To lvDir.ListItems.Count
If lvDir.ListItems(i).Selected = True Then
'do whatever
End If
Next i
when i use this it just returned the text of the first item selected the number of times there are selected items.. so if the first item selected is a 2. and 10 things are selected, in debug.print 2 will show up 10 times... anyone have any input? thanks,
-gabe
Multiple Select In Listview Control
I have a list view control that has 10 items in it. Also on my form I have a remove button, so when the user selects multiple items, they can remove the selected. but heres where i get some trouble. i use
listview.listitems.count
to return the number of items in the listview so that i can loop through and use the
listview.listitems(i).selected=true
to determine whether an item was selected. so my code looks like this:
dim i as integer
for i = 1 to listview.listitems.count
if listview.listitems(i).selected=true then
listview.listitems.remove (i)
end if
next i
but i end up with an index out of bounds error. this is why i think this is happening. referring back to my senario of 10 items, i select 5 to be removed and as it loops through and removes them 1 by 1 the count is decremented by one, so when it reaches the last item in the listview, there is only 5 left but it continues to try to count to 10 because the count says there is 10 when in reality there is only 5. but i cann't set the count to a variable, for example say "c" and then step from 1 to "c", and then when i removed an item decrement "c" by 1. i think once your stepping from 1 to x (where x is any number) your commited to that, regardless. HELP!!!!! thanks in advance.
Select Multiple Files From Listview And Remember Them ?
Well if i select one item from a listview its remembered as
me.listview1.selected item.text or listview1.selecteditems.text etc,
if i were to select a number of items from the listview how would i call back the list that i'd selected ?
So if i selected the first 5 items in the list i then want to be able to display the those items when needed i guess the code should be something like,
msgbox(listview1.selecteditem(s).text) but that doesnt seem to be a standard function. ?
Get Items / Select Items From MSAccess Form Controls
Hello,
I am supposed to automation one application which is developed in MSAccess Form. None of the automation tools support AccessFormControls.
What i did was, i get into VB, tried to do that using Win32API.
i am able to active the window, and get the child windows. But there is one sub form in the form itself. And the controls are populatd on the form. And it will be dynamic.
I am not able to enumerate the controls in it.
Can anybody help me on this?
Prevent Multiple Select In Multiple Combos
Hi,
I have a control array of 13 combo boxes cmb6Pos(0) to cmb6Pos(12) that are all loaded with the same list of alphanumeric codes. How can I prevent a code from being selected in a combo box if it has already been selected in another?
Any pointers or code would be great, thanks,
Mat
Select Items
Hi Everyone,
Is there anyway to select multiple items in a ListView through code? For example, place a text box on the form and have the user type User Id's into the box separated by a space, semi colon, comma or something like that. Then when the user hits enter all of the ID's that were in the text box would be selected. Thanks for any help.
Select All Items In A Listbox
How can I select all the items in a listbox via click a button on a form?
I have tried and tried I just cannot get it!
Thanks in advance.
How To Select Items From Listbox
Hey guys I have this assignment where i am to create a calculator as attached:
Basically I am to input the 2 inputs to be calculated into the 2 input boxes lst v1 and v2, and select from the lst Oper box the function I wish to perfrom for example +, -, / and * my question is, is how within the program do i make it so that the item selected by the user within the lstOper box is performed? i understand if it were a button but how can i get the program to understand that i have selected that particular function from the list either being a plus or minus?
Listbox Select Items
I have a listbox that presents 2 different numbers on each line of the listbox, they are related form a previous calculation and appended together with 5 blank spaces between the numbers so the user can tell them apart when they are scrolling down the list. I want to have the user click on one of these items, the 2 numbers, in the listbox, and display just one of the numbers.
Can I trim that particular variable in the listbox somehow after I've selected it? so only one of the numbers can be presented in another textbox.
Or better yet, can I have two different listboxes that are related somehow so when the user selects something on one box it automatically selects the related item on the same line in the other listbox. Then I won't have to append in the first place and will have better control over the variables.
Thanks
Select All Items In List Box?
How would I go about selecting all the items in the list box?
Im trying to get a list of names in a list box and select them all at the sametime
How To Select Items From List Box
Hi,
Thank you all for the wonderful help. I am struck with Inputbox which creates lot of problem while the user by mistake clicks cancel button. My requirement is that the user should be able to select from list box the reason code which are five in number (1,2,3,4,5). This number should replace a digit in another list box.
As soon as the first list box item is clicked it should prompt the user to select the item from listbox2. By doing so I can restrict the user to use one of the Listbox items (1,2,3,4,5). Can anyone help me in this regard.
Add Items From SELECT Statement Only Once
Hello,
As you can see the following code would put the results found in the database in a listbox:
VB Code:
With cnTeamCMI .ConnectionString = sConnString .ConnectionTimeout = 0 .CursorLocation = adUseClient .Open strConnString End With sSQl = "SELECT [EMPLOYEE NAME] FROM [TIMINGS] WHERE [DATE ENTERED] = #" & Format(Now, "mm/dd/yy") & "#" Debug.Print sSQl rsTempRecordSet.Open sSQl, cnTeamCMI, adOpenStatic, adLockReadOnly With rsTempRecordSet If Not (.EOF And .BOF) Then Do While Not .EOF lstHere.AddItem ![EMPLOYEE NAME] .MoveNext Loop End If .Close End WithSet rsTempRecordSet = NothingSet cnTeamCMI = Nothing
The problem is that the database has many records to the extent that the employee is being added to the listbox over 60 times. how can I modify the above code to make it add the employee name only once?
Thankx in advance!
Select All Index Items
I have a form with three items on it. each item has 60 index's
WebAddress(0) - WebAddress(60)
btnGO(0) - btnGO(60)
Label(0) - Label(60)
when the form loads it hides all of the items that have nothing in the webaddress text box. so if there is no address in WebAddress(12) it will hide WebAddress(12) btnGO(12) and Label(12)
when I edit the form I want to show all of the items so I can manually type in the web address. Is there a fast way to select all the items and make them visible?
Thanks,
Mike
How To Select Items In Listbox ?
Like say my first item was the word house, i want to click a command button and save that word to a txt file, then save the next item in the list to the same text file but appended then the next item, and so on ?
thanks
Select Items From MSHFlexGrid?
I have a form with a MSHFlexGrid (frmInvoice) and I am calling items from a SQL Database to load another MSHFlexGrid (frmChoose). The frmChoose needs to pull up parts from a database. Most parts have 2 choices(OEM and ReMan) When I use the SQL Statement I only get one part and not the other.
"Select * from Parts Where PartName = 'WaterPump'"
I'm sure I have to include the "i" counter but can't quite seem to figure it out.
Also I need to be able to select a row from the frmChoose and add it to the frmInvoice.
I call PartName because even though it's not the primary key, I have taken time to make sure all PartNames are unique.
Select All Items In A DataGrid ( Still Need Help )
Hi,
Is there a way to select all the items in a datagrid. I use this code.
Code:
rstCommandePrevisualise.MoveLast
While Not rstCommandePrevisualise.BOF
dbgCommande.SelBookmarks.Add rstCommandePrevisualise.Bookmark
rstCommandePrevisualise.MovePrevious
Wend
But if my grid contains 3000 records, it takes a while to select all of them. Is there a method to use to select all rows.
Edited by - ndbu on 4/21/2004 10:22:32 AM
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
|