Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. Opening a document from a DataTable

Opening a document from a DataTable

Scheduled Pinned Locked Moved C#
databasehelp
2 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Darkness84
    wrote on last edited by
    #1

    I need some help with being able to open a document that is listed in a datatable and is displayed in a datagridview. The code below returns a series of results from a database and these results include the file paths of files on my computer. What I want to be able to do is doulble click on a particular file path in the link column and have that file open.

    Hits hits = searcher.Search(query);
    DataTable dt = new DataTable();
    dt.Columns.Add("link", typeof(string));
    for (int j = 0; j < hits.Length(); j++)
    {
    // get the document from index
    Document doc = hits.Doc(j);
    // get the document filename
    DataRow row = dt.NewRow();
    row["link"] = doc.Get("link");
    dt.Rows.Add(row);
    }
    MessageBox.Show("Search Complete", "", MessageBoxButtons.OK);
    return dt;

    D 1 Reply Last reply
    0
    • D Darkness84

      I need some help with being able to open a document that is listed in a datatable and is displayed in a datagridview. The code below returns a series of results from a database and these results include the file paths of files on my computer. What I want to be able to do is doulble click on a particular file path in the link column and have that file open.

      Hits hits = searcher.Search(query);
      DataTable dt = new DataTable();
      dt.Columns.Add("link", typeof(string));
      for (int j = 0; j < hits.Length(); j++)
      {
      // get the document from index
      Document doc = hits.Doc(j);
      // get the document filename
      DataRow row = dt.NewRow();
      row["link"] = doc.Get("link");
      dt.Rows.Add(row);
      }
      MessageBox.Show("Search Complete", "", MessageBoxButtons.OK);
      return dt;

      D Offline
      D Offline
      Darkness84
      wrote on last edited by
      #2

      I have solved the problem, just in case anyone is interested.

      private void dgv_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e)
      {
      SearchIndex search = new SearchIndex();
      search.docOpen(this.dgv.CurrentCell.Value.ToString());
      }

      public void docOpen(string path)
      {
      Process proc = new Process();
      proc.StartInfo.FileName = "iexplore";
      proc.StartInfo.Arguments = path;
      proc.Start();
      }

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups