Hi friends
I want to know how to insert data in listview.
Thank you.
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Kunal VaishyaRank #990 · 2K reputationPosted May 14, 2012, 3:23 AM EDT
In Window application
string[] row1 = { "s1", "s2", "s3" }; listView1.Items.Add("Column1Text").SubItems.AddRange(row1);And a more verbose way is here:
ListViewItem item1 = new ListViewItem("Something"); item1.SubItems.Add("SubItem1a"); item1.SubItems.Add("SubItem1b"); ListViewItem item2 = new ListViewItem("Something2"); item2.SubItems.Add("SubItem2a"); item2.SubItems.Add("SubItem2a"); ListViewItem item3 = new ListViewItem("Somethin3"); item3.SubItems.Add("SubItem3a"); item3.SubItems.Add("SubItem3a"); ListView1.Items.AddRange(new ListViewItem[] {item1,item2,item3}); More reference refer http://stackoverflow.com/questions/473148/c-sharp-listview-how-do-i-add-items-to-columns-2-3-and-4-etcEhteshamRank #3,979 · 374 reputationPosted May 14, 2012, 3:55 AM EDT
Consider the below example for tile view with item image
public partial class Form1 : Form
{
ImageList ImgLst = null;
public Form1()
{
InitializeComponent();
listview1.View = View.Tile;
ImgLst = new ImageList();
//Adding image from resource to ImageList
ImgLst.Images.Add(Properties.Resources.img);
listView1.LargeImageList = ImgLst;
ListViewItem Lstitem = new ListViewItem("Item name1", 0);
listView1.Items.Add(Lstitem);
Lstitem = new ListViewItem("Item name2", 0);
listView1.Items.Add(Lstitem);
}
}