private void tbldocDataGridView_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e) { if (e.RowIndex >= 0) { DataGridViewRow selectedRow = tbldocDataGridView.Rows[e.RowIndex]; tbldoc selectedrow = selectedRow.DataBoundItem as tbldoc; var qry = from doc in dblite.tbldoc where doc.id == selectedrow.id join data in dblite.tblData on doc.id equals data.id select new { Id = doc.id, kilde_sti = doc.kilde_sti, Data = data.data }; foreach (var rec in qry) { FileInfo fi = new FileInfo(rec.kilde_sti); var Ext = fi.Extension; var Name = fi.Name; if (Ext.ToLower() == ".pdf") { byte[] bytes = rec.Data; m_frmIE = new frmIE(); m_frmIE.WebBrowser1.LoadBytes(bytes, MediaTypeNames.Application.Pdf); m_frmIE.Show(); } } } }
private void visDokumentToolStripMenuItem_Click(object sender, EventArgs e) { DataGridViewSelectedCellCollection cells = tbldocDataGridView.SelectedCells; if (cells.Count > 0) { try { DataGridViewTextBoxCell cell = cells[0] as DataGridViewTextBoxCell; tbldoc rec_doc_view = cell.OwningRow.DataBoundItem as tbldoc; var rec = (from doc in dblite.tbldoc where doc.id == rec_doc_view.id join data in dblite.tblData on doc.id equals data.id select new { Id = doc.id, kilde_sti = doc.kilde_sti, Data = data.data }).First(); FileInfo fi = new FileInfo(rec.kilde_sti); var Ext = fi.Extension; var Name = fi.Name; if (Ext.ToLower() == ".pdf") { byte[] bytes = rec.Data; m_frmIE = new frmIE(); m_frmIE.WebBrowser1.LoadBytes(bytes, MediaTypeNames.Application.Pdf); m_frmIE.Show(); } } catch { } } }