永发信息网

C#如何把listview中的项导入到记事本里面

答案:2  悬赏:10  手机版
解决时间 2021-04-29 08:37
  • 提问者网友:我是女神我骄傲
  • 2021-04-28 17:45
C#如何把listview中的项导入到记事本里面
最佳答案
  • 五星知识达人网友:西岸风
  • 2021-04-28 18:49

应该是要打印选中项吧,我这儿有做完的代码:


private void btnPrint_Click(object sender, EventArgs e)
{
try
{
string setName = this.cboSets.Text;

if (this.lvSets.SelectedItems.Count == 0)
{
MessageBox.Show("没有选择删除项。");
}
else
{
int index = this.lvSets.SelectedItems[0].Index;
FileStream fs = new FileStream("iteminfo.txt", FileMode.Create);
StreamWriter sw = new StreamWriter(fs);
switch (setName)
{
case "套餐A":
sw.WriteLine("检查项目名称:{0}", setA.Items[index].Name);
sw.WriteLine("功能描述:{0}", setA.Items[index].Description);
sw.WriteLine("单价:{0}元", setA.Items[index].Price);
break;
case "套餐B":
sw.WriteLine("检查项目名称:{0}", setB.Items[index].Name);
sw.WriteLine("功能描述:{0}", setB.Items[index].Description);
sw.WriteLine("单价:{0}元", setB.Items[index].Price);
break;
}
sw.Close();
fs.Close();
MessageBox.Show("打印成功。");
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}

全部回答
  • 1楼网友:狂恋
  • 2021-04-28 19:26
IO流。。。fileStream
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯