.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> C# >> Post New QuestionBookmark and Share Subscribe to Forum

How to add values to perticular column in listview in c#.net?

Posted By: chandrakant     Posted Date: April 04, 2011    Points:5   Category :C#
How to add values to perticular column in listview in c#.net?


Please Help?


Thanks in Advance

Chandrakant Kadu

Responses
Author: Mahesh             
Posted Date: April 04, 2011     Points: 20   

hi,

There are several way to do it, but here is one solution (for 4 columns).

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});

Thanks & Regards
Mahesh

Author: Maverick             
Posted Date: April 06, 2011     Points: 20   

Hello,

Use
lstItem.subitems.add("uritem");

Thanks,
Maverick

Thanks,
Maverick


Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend