Multiple Columns in listview

余生颓废 提交于 2019-12-13 00:41:07

问题


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.


回答1:


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

lstView.View = View.Details;



回答2:


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


来源:https://stackoverflow.com/questions/12467557/multiple-columns-in-listview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!