How get listview co...
 
Notifications
Clear all

[Solved] How get listview control data in c#  

  RSS

sels2005j
(@sels2005j)
New Member
Joined: 8 years ago
Posts: 4
23/05/2018 12:43 pm  

I Friends,

I am trying to get the data of a listview controls all column data to textboxes. My code is as below.

this.Text1.Text = this.listview1.SelectedItems[0].Text;
this.Text2.Text = this.listview1.SelectedItems[1].Text;
this.Text3.Text = this.listview1.SelectedItems[2].Text;

I get the error :

InvalidArgument=Value of '0' is not valid for 'index'.\r\nParameter name: index

Please help me to solve this issue.

 


Quote
seevablog
(@seevablog)
Member Admin
Joined: 8 years ago
Posts: 1
24/05/2018 1:33 pm  

Hi,

Please use the below code :

this.Text1.Text = this.listview1.SelectedItems[0].SubItems[0].Text;
this.Text2.Text = this.listview1.SelectedItems[0].SubItems[2].Text;
this.Text3.Text = this.listview1.SelectedItems[0].SubItems[3].Text;

I hope this will help you.

Thanks


sels2005j liked
ReplyQuote
sels2005j
(@sels2005j)
New Member
Joined: 8 years ago
Posts: 4
25/05/2018 10:47 am  
Posted by: seevablog

Hi,

Please use the below code :

this.Text1.Text = this.listview1.SelectedItems[0].SubItems[0].Text;
this.Text2.Text = this.listview1.SelectedItems[0].SubItems[2].Text;
this.Text3.Text = this.listview1.SelectedItems[0].SubItems[3].Text;

I hope this will help you.

Thanks

Thank you very much.

It solved my issue.


ReplyQuote