VS2010 C# 为什么listview只能选中第一列的单个单元格?
privatevoidInitializeListView(){try{listView1.View=View.Details;stringfilePath=Enviro...
private void InitializeListView() { try { listView1.View = View.Details; string filePath = Environment.CurrentDirectory + "\\药价表.txt"; using (FileStream fs = new FileStream(filePath, FileMode.Open)) { using (StreamReader sr = new StreamReader(fs, System.Text.Encoding.GetEncoding("gb2312"))) { string line;while (sr.Peek() >= 0) { line = sr.ReadLine(); string[] columns = line.Split(new string[] { " ", "\t" }, StringSplitOptions.RemoveEmptyEntries); ListViewItem newItem = new ListViewItem(columns[0]); newItem.SubItems.Add(columns[1]); newItem.SubItems.Add(columns[2]); listView1.Items.Add(newItem); } } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询