private void 导出成功点击ToolStripMenuItem_Click(object sender, EventArgs e)
{
if (listCount.Items.Count == )
{
MessageBox.Show("列表为空!");
}
else {
List<string> list = new List<string>();
foreach (ListViewItem item in listCount.Items)
{
string temp = item.SubItems[].Text;
list.Add(temp);
}
Thread thexp = new Thread(() => export(list)) { IsBackground = true };
thexp.Start();
}
}
private void export(List<string> list)
{
string path = AppDomain.CurrentDomain.BaseDirectory + "url_" + Guid.NewGuid().ToString() + ".txt";
StringBuilder sb = new StringBuilder();
foreach (string tel in list)
{
sb.AppendLine(tel);
}
System.IO.File.WriteAllText(path, sb.ToString(), Encoding.UTF8);
txtmsg.BeginInvoke(new Action(() => {
string temp = "文件导出成功!文件地址:" + path;
txtmsg.AppendText(temp.SetLog());
}));
}

自己写的,并且测试可用,才发上来的!!!!

就是循环listview.items,然后,装到一个list<string>集合,然后。。。。

看代码吧。

C# listview控件右击导出数据到txt文本的更多相关文章

  1. C#跨进程读取listview控件中的数据

    http://www.cnblogs.com/Charltsing/p/slv32.html 欢迎交流:QQ564955427 读取标准的32位listview控件中的数据,网上已经有很多代码了.今天 ...

  2. 使用Listview控件显示数据

    1.图像列表控件 ImageList是含有图像对象的集合,可以通过索引或关键字引用该集合中的每个对象. ImageList空间的属性 属性 说明 Images 存储在图像列表中的所有图像 ImageS ...

  3. WinForm 之 使用ListView控件展示数据

    在学习了这么多的WinForm基本控件后,今天在来学习一个比较有意思的包含图片的控件! >>>图像列表控件 ImageList是含有图像对象的集合,可以通过索引或关键字引用该集合中的 ...

  4. Windows程序==>>使用ListView控件展示数据

    使用ListView控件展示数据 01.ImageList控件 1.了解了解         属性 说明 Images 储存在图像列表中的所有图像 ImageSize 图像列表中图像的大小 Trans ...

  5. 机房收费系统——在VB中将MSHFlexGrid控件中的数据导出到Excel

    机房收费系统中,好多查询的窗体都包含同一个功能:将数据库中查询到的数据显示在MSHFlexGrid控件中,然后再把MSHFlexGrid控件中的数据导出到Excel表格中. 虽然之前做过学生信息管理系 ...

  6. 将数据库数据添加到ListView控件中

    实现效果: 知识运用: ListView控件中的Items集合的Clear方法 //从listView控件的数据项集合中移除所有数据项 补充:可以使用Remove或RemoveAt方法从集合中移除单个 ...

  7. WPF-将DataGrid控件中的数据导出到Excel

    原文:WPF-将DataGrid控件中的数据导出到Excel 导出至Excel是非常常见,我们可以用很多类库,例如Aspose.NOPI.Interop,在这里我们使用微软自家的工具.我的WPF绑定的 ...

  8. C#中向ListView控件中添加一行数据

    C#中向ListView控件中添加一行数据: ,先声明一个ListViewItem: ListViewItem item = new ListViewItem(); ,添加第一列数据: item.Te ...

  9. C#在listview控件中显示数据库数据

    一.了解listview控件的属性 view:设置为details columns:设置列 items:设置行 1.将listview的view设置为details 2.设置列属性 点击添加,添加一列 ...

随机推荐

  1. OSX系统添加定时任务 Linux crontab命令 定时执行py 文件 任务

    #输出日志 #将日志输入到2.log文件中无论错误还是正确02 15 * * * . ~/xad/pyenv/xadserver/bin/activate && cd /root/xa ...

  2. Delphi调用JAVA的WebService上传XML文件(XE10.2+WIN764)

    相关资料:1.http://blog.csdn.net/luojianfeng/article/details/512198902.http://blog.csdn.net/avsuper/artic ...

  3. Eigen教程(9)

    整理下Eigen库的教程,参考:http://eigen.tuxfamily.org/dox/index.html Eigen并没有为matrix提供直接的Reshape和Slicing的API,但是 ...

  4. virtualbox问题收集

    The VM session was closed before any attempt to power it on. 返回 代码:E_FAIL (0x80004005)组件:SessionMach ...

  5. 集成 IBM Business Process Manager V8 与企业内容管理系统

    连接:http://www.ibm.com/developerworks/cn/bpm/bpmjournal/1212_ramos/1212_ramos.html 集成 IBM Business Pr ...

  6. git拉取远程分支

    查看本地所有分支列表: git branch -a 查看远程所有分支列表: git branch -r 拉取远程分支(使用该方式会在本地新建分支x,但是不会自动切换到该本地分支x,需要手动checko ...

  7. 【WPF/WAF】使用System.Windows.Interactivity交互事件

    下载System.Windows.Interactivity.dll文件,并引入项目中(在VS项目的引用列表中可以看到).可在Nuget搜索System.Windows.Interactivity下载 ...

  8. C++11中如何输出enum class的值

    Unlike an unscoped enumeration, a scoped enumeration is not implicitly convertible to its integer va ...

  9. Aspose Linux下字体找不到报错

    http://www.aspose.com/docs/display/cellsnet/Smart+Markers http://www.aspose.com/docs/display/cellsja ...

  10. Selenium (1) —— Selenium安装与测试(101 Tutorial)

    Selenium (1) -- Selenium安装与测试(101 Tutorial) jvm版本: 1.8.0_65 selenium版本: v2.48.0 (Standalone Selenium ...