从数据网格视图保存内容 [英] Saving Content From A Data Grid View
本文介绍了从数据网格视图保存内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
How can i save the contents of a Data Grid View in to a text file? as well as Open it back up?
推荐答案
我不知道这是否是最佳解决方案,但它对我有用.
I don''t know whether this is the best solution or not but it works for me.
private void btn_export_Click(object sender, EventArgs e)
{
foreach (DataGridViewRow dgvr in DataGridViewRow.Rows)
{
int cells = dgvr.Cells.Count;
for (int i = 0; i < cells; i++)
{
File.AppendAllText("contents.txt",dgvr.Cells[i].Value.ToString()+" ");
}
}
}
这篇关于从数据网格视图保存内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文