NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

Like every other website we use cookies. By using our site you acknowledge that you have read and understand our Cookie Policy, Privacy Policy, and our Terms of Service. Learn more
Ask me later
Decline
Allow cookies
Click here to Skip to main content
14,890,092 members
Sign in
Home


home
articles
Browse Topics>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Visual Basic questions
View Javascript questions
View Python questions
discussions
All Message Boards...
Application Lifecycle>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices>
System Admin
Hosting and Servers
Java
Linux Programming
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
Competitions
Conferences
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
Product Showcase
CodeProject Stuff
community
Who's Who
Most Valuable Professionals
The Lounge
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us

Ask a Question
All Questions All Unanswered FAQ
add items (text) to multicollumn listview in a for loop
0.00/5 (No votes)
See more: VB
I have created 2 collumns in a listview vb net 2012, how can I add text in columns?
this works :
VB
Copy Code

ListView1.Items(0).SubItems(0).Text = x.ToString


but how can I add multiple values in a for...next loop
this doesn't work
VB
Copy Code

For c = 0 To 10.....
ListView1.Items(c).SubItems(0).Text = x.ToString

Posted 2-Jul-15 20:23pm
Member 3892343
Updated 2-Jul-15 21:20pm
v3
Add a Solution
Comments
Michael_Davies 3-Jul-15 2:48am

Question is confusing, you say "add items text", you say ListView but the code shows DataGridView, from that I presume therefore that you have already loaded the DGV with items and are then wanting to populate the ListView with the first column of the DGV.

If you are loading a ListView from a DataGridView then you need to ADD to the ListView:

For Each Line As DataGridViewRow In DataGridView1.Rows
ListView1.Items.Add(New ListViewItem(Line.Cells.Item(0).Value))
next

If you are UPDATING the ListView which already contains the text from the DGV rows you have to locate the correct ListViewItem as there may not be a one to one correspondence between the controls i.e. no guarantee that row 1 of the DGV is the row 1 of the LV, the LV might have been sorted differently.

Once located just : ListView1.Items(c).Text = x.tostring
1 solution
Solution 1
VB
Copy Code

For i = 0 To 10
ListView1.items.add(("fdghhdhd").subitems.Add("fdghhdhd")


found it thank you michael for the comment
Permalink
Posted 2-Jul-15 21:35pm
Member 3892343
Updated 2-Jul-15 22:35pm
v2
Add your solution here
Preview


Existing Members
Sign in to your account

...or Join us
Download, Vote, Comment, Publish.
Your Email
Password
Forgot your password?

Your Email
Optional Password

I have read and agree to the Terms of Service and Privacy Policy
Please subscribe me to the CodeProject newsletters
Submit your solution!
When answering a question please:

Read the question carefully.
Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.

Let's work to help developers, not make them feel stupid.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)
Print Answers RSS
Top Experts
Last 24hrs This month
Richard MacCutchan 195
OriginalGriff 160
Rick York 140
RickZeeland 50
k5054 50

OriginalGriff 4,858
Richard MacCutchan 2,599
Patrice T 1,272
Dave Kreskowiak 895
CPallini 700
Related Questions
ListView Control Items Add by For Loop
Windows form ListView add item in C#
how to add item in listview on top
add selected listview items into an array
How to print vb6 listview items
Listview Selected Item
How to directly get listview item text by specifying item tag
Get listview checked item [Loop]
how to add the total of items in listview column and display the result in a text box
Iterate listview items in WPF C#


Advertise
Privacy
Cookies
Terms of Use
Last Updated 3 Jul 2015
Layout: fixed | fluid
Copyright © CodeProject, 1999-2021
All Rights Reserved.

Web05 2.8.20210514.1

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.