日期:2014-05-17  浏览次数:20834 次

怎样在C#的DataGridView的单元格中直接打开对应文件
我现在在DataGridView的单元格中设置了一个DataGridViewButtonColumn,一个DataGridViewTextBoxColumn,DataGridViewTextBoxColumn中显示的是数据库中存放的文件路径,我想点击DataGridViewButtonColumn按钮时就打开对应DataGridViewTextBoxColumn显示的文件路径的的文件,并将所打开的文件内容显示在RichTextBox上。

------解决方案--------------------
新手仅供参考:
所读取文件是txt格式的话,根据取得的文件路径把txt内容读取,并进行相应的拼接

参考:http://blog.csdn.net/zhangxinbin5/article/details/7927772
------解决方案--------------------
DataGridViewButtonColumn btn = new DataGridViewButtonColumn();
btn.name="btn";
btn.HeaderText= "查询";
btn.DefaultCellStyle.NullValue = "查询";
 
//按钮操作
private void dgv_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
}
------解决方案--------------------
C# code
用 Process.Start()