创建一列datagridview的记事本文件. [英] create notepad file of one column of datagridview.

查看:70
本文介绍了创建一列datagridview的记事本文件.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我有datagridview之类的...

srno名称联系人

1杰克9999999999
2尼尔8888888888
3 Vicky 9898988989


我有一个按钮可以按下gridview.

我想创建仅联系人号码的记事本文件,例如...

9999999999
8888888888
9898989898

解决方案

只需快速...


在您创建了datagridview的某个地方...我会假装它叫做dg

  Dim  dg  As   DataGridView 



您可以创建一个流写入器,遍历数据网格的每一行,然后将Contact列中的数据写入该流写入器.确保使用WriteLine而不是Write.否则,您将必须手动添加VBCRLF.

  Dim  s  As   StreamWriter(" )
对于 每个 r  As  DataGridViewRow 在行中
    s.WriteLine(r.DataBoundItem.Row(" )
下一步
s.Close()


hi
i have datagridview like...

srno name contact

1 Jack 9999999999
2 Nill 8888888888
3 Vicky 9898988989


i have one button blow the gridview.

i want to create notepad file of only contact number like...

9999999999
8888888888
9898989898

解决方案

Just quickly...


Somewhere you''ve created your datagridview... I''ll pretend it''s called dg

Dim dg As New DataGridView



You can create a streamwriter, iterate through each row of the datagrid, and write the data in the Contact column to the streamwriter. Make sure to use WriteLine instead of Write. Otherwise, you''ll have to manually add the VBCRLF.

Dim s As New StreamWriter("Filename")
For Each r As DataGridViewRow In dg.Rows
    s.WriteLine(r.DataBoundItem.Row("Contact")
Next
s.Close()


这篇关于创建一列datagridview的记事本文件.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆