毕业论文开发语言企业开发JAVA技术.NET技术WEB开发Linux/Unix数据库技术Windows平台移动平台嵌入式论文范文英语论文
您现在的位置: 毕业论文 >> net技术 >> 正文

c# listview 导入txt 加序号

更新时间:2013-6-23:  来源:毕业论文

c# listview 导入txt 加序号

我有一段数据

123-123

456-456

789-789

用openfiledialog导入listview,需要分割,

然后在前面加一栏序号,怎么实现啊

using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.IO;   namespace WindowsFormsApplication22 {     public partial class Form1 : Form     {         public Form1()         {             InitializeComponent();         }           private void Form1_Load(object sender, EventArgs e)         {             int couns=0;             listView1.View = View.Details;             ColumnHeader ch1 = new ColumnHeader();             ch1.Text = "序号";             ColumnHeader ch2=new ColumnHeader();             ch2.Text = "账号";             ColumnHeader ch3=new ColumnHeader();             ch3.Text = "密码";             listView1.Columns.Add(ch1);             listView1.Columns.Add(ch2);             listView1.Columns.Add(ch3);             OpenFileDialog file = new OpenFileDialog();             if (file.ShowDialog() == DialogResult.OK) {                 FileStream fs=new FileStream(file.FileName,FileMode.Open);                 StreamReader sr = new StreamReader(fs);                 sr.BaseStream.Seek(0, SeekOrigin.Begin);                 while (!sr.EndOfStream) {                            string[] ss = sr.ReadLine().Split(new char[] { '-' }, StringSplitOptions.RemoveEmptyEntries);                     if (ss.Length == 2)                     {                         couns++;                         string[] sss = new string[3] { couns.ToString(), ss[0], ss[1] };                         ListViewItem lvi = new ListViewItem(sss);                         listView1.Items.Add(lvi);                     }                 }             }         }     } }

设为首页 | 联系站长 | 友情链接 | 网站地图 |

copyright©youerw.com 优尔论文网 严禁转载
如果本毕业论文网损害了您的利益或者侵犯了您的权利,请及时联系,我们一定会及时改正。