1

I am writing the following code in C# to show data in multiple columns in a listView but it only shows the first element of the array,

ListViewItem item = new ListViewItem(new []{txtTitle.Text,txtRatings.Value.ToString(),cmbGenre.Text});
lstMovie.Items.Add(item);

the output in the list view is just the first element. How do I get all three elements.

2 Answers 2

4

The data was inserted but listview was not displaying it, set listView's View property to Details

lstView.View = View.Details;
Sign up to request clarification or add additional context in comments.

Comments

1

Have you added the 3 columns to your listview before trying to populate it? Something like:

lstMovie.Columns.Add("Title");
lstMovie.Columns.Add("Ratings");
lstMovie.Columns.Add("Genre");

1 Comment

Yes figured it out, I had to set my list.view to details lstMovie.View = View.Details

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.