|
-
Oct 6th, 2009, 10:44 AM
#1
Thread Starter
PowerPoster
MULTISELECT listview items...
I have a listview filled with value.
Is possible to select one or more line in listy view and store the value of first item in a sheet.
Example:
in listview
column1 column2 column3
10000 aaaaaaaa bbbbbbbb
15000 zzzzzzzzz cccccccc
...
20000 hhhhhhhh adababab
i select line 1 and line 2
the lines seected assuming autoamticlly the black color
insert in sheet:
column a column b column c
10000 aaaaaaaa bbbbbbbb
15000 zzzzzzzzz cccccccc
naturally if i reclick on line 1 and 2 in listview delete the refered line in sheet and recolr the line in listview with the color of deault...
Sorry for bad english but i hope understand me:-)
-
Oct 6th, 2009, 11:32 AM
#2
Re: MULTISELECT listview items...
Not sure if I understand you but
Select 2 rows in a listview.
Copy to Excel
Paste
Where is this listview at?
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Oct 6th, 2009, 11:41 AM
#3
Re: MULTISELECT listview items...
I am assuming that you are using Excel 2003...
Here is a sample code to export data from listview to excel sheet....
vb Code:
'~~> Generating Sample Data. Private Sub UserForm_Activate() '~~> Ensure that the listview's multiselect property is set to true Dim clmAdd As ColumnHeader, itmAdd As ListItem, j As Integer '~~> Adding 3 Column Headers to the ListView control Set clmAdd = ListView1.ColumnHeaders.Add(Text:="Header1") Set clmAdd = ListView1.ColumnHeaders.Add(Text:="Header2") Set clmAdd = ListView1.ColumnHeaders.Add(Text:="Header3") '~~> Set the view property of the Listview control to Report view ListView1.View = lvwReport '~~> Adding Sample data to the ListView control For j = 1 To 5 Set itmAdd = ListView1.ListItems.Add(Text:="Sample " & j) itmAdd.SubItems(1) = "SampleSubItemOne" & j itmAdd.SubItems(2) = "SampleSubItemTwo" & j Next j End Sub '~~> Export Data to Sheet from listview Private Sub CommandButton1_Click() Dim i As Integer, R As Integer '~~> Get the First Empty Row R = Sheets("Sheet1").Range("A65536").End(xlUp).Row + 1 For i = 1 To ListView1.ListItems.Count If ListView1.ListItems(i).Selected = True Then '~~> Data copied to Column A, B and C Sheets("Sheet1").Range("A" & R).Value = ListView1.ListItems(i).Text Sheets("Sheet1").Range("B" & R).Value = ListView1.ListItems(i).SubItems(1) Sheets("Sheet1").Range("C" & R).Value = ListView1.ListItems(i).SubItems(2) R = R + 1 End If Next i End Sub
I am sure you can take care of
naturally if i reclick on line 1 and 2 in listview delete the refered line in sheet and recolr the line in listview with the color of deault...
If you get stuck, simply post the code that you have tried and we will definitely help you out
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|