双击datagrid视图以打开电子邮件

时间:2009-11-23 11:47:29

标签: c# winforms datagridview

这是针对使用c#的winforms 我有一个datagridview,它列出了文件夹中的电子邮件消息(.msg)。

我的目标:如果用户双击datagridview中的单元格,则必须打开相应的电子邮件以供查看

我该怎么做?

2 个答案:

答案 0 :(得分:2)

您将msg文件的路径存放在哪里?然后,您可以使用CellDoubleClickCellMouseDoubleClick事件使用Process.Start打开msg文件。我假设已安装outlook并且MSG文件与outlook相关联。希望这能提供足够的信息编写自己的代码

答案 1 :(得分:0)

您需要找出首先选择哪一行,然后获取实际选择它的单元格并截取datagridview鼠标事件处理程序(双击)以触发消息的加载。 举个例子
private void dataGridView1_DoubleClick(object sender, EventArgs e)
{
 // Check if the selected cell count is 1 only
  if (this.dataGridView1.SelectedCells.Count == 1)
  {
   DataGridViewSelectedCellCollection col = this.dataGridView1.SelectedCells;
   // Example: The column of a selected row contains the value Msg
   if (col[0].Value == "Msg")
    {
     // Trigger the load mechanism
    }
  }
}

希望这能给你正确的方向, 最好的祝福, 汤姆。

相关问题