You can raise the DoubleClick event if you are displaying the data in DataGrid and write the view code inside
try
{
if (dataGridView1.RowCount > 0)
{
DataGridViewRow row = dataGridView1.CurrentCell.OwningRow;
document_type = row.Cells[7].Value.ToString();
tag11 = row.Cells[1].Value.ToString();
tag22 = row.Cells[2].Value.ToString();
tag33 = row.Cells[3].Value.ToString();
tag44 = row.Cells[4].Value.ToString();
date1 = row.Cells[8].Value.ToString();
}
if (dataGridView2.RowCount > 0)
{
DataGridViewRow row = dataGridView1.CurrentCell.OwningRow;
document_type = row.Cells[7].Value.ToString();
}
if (
document_type == "Image"
|| document_type == "Pdf Document"
|| document_type == "Audio"
|| document_type == "Video"
|| document_type == "Text"
)
{
DocumentView view = new DocumentView(documentname);
view.ShowDialog();
view_count();
}
else
{
int lng = Application.ExecutablePath.Length; ;
int lng2 = lng - 18;
string pth = Application.ExecutablePath.Substring(0, lng2);
string destinationfolder = pth + "Documents";
string save_path1 = destinationfolder + @"\" + documentname;
System.Diagnostics.Process.Start(save_path1);
}
}
catch (Exception e3)
{
int lng = Application.ExecutablePath.Length; ;
int lng2 = lng - 18;
string pth = Application.ExecutablePath.Substring(0, lng2);
string destinationfolder = pth + "Documents";
string save_path1 = destinationfolder + @"\" + documentname;
MessageBox.Show("System Or Windows can not open the Selected Document");
System.IO.StreamReader sr = new
System.IO.StreamReader(save_path1);
MessageBox.Show(sr.ReadToEnd());
sr.Close();
}