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
  1. Home
  2. General Programming
  3. C#
  4. Store a pointer in a DataGridView cell? (or other method of referencing a pointer) [modified]

Store a pointer in a DataGridView cell? (or other method of referencing a pointer) [modified]

Scheduled Pinned Locked Moved C#
csshelpquestion
3 Posts 2 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.
  • A Offline
    A Offline
    alanteigne
    wrote on last edited by
    #1

    Hello, I'm writing a ALT+TAB-ish app that pops up due to a hotkey. It currently displays a list of currently running applications (using EnumWindows & GetWindowText) as a row in a DataGridView and I've created a event handler to run when a row is double clicked on. I'm hoping to use SetForeGroundWindow from User32.dll to bring the selected app to the front. This requires a pointer (IntPtr) to be passed, which I have available when populating my grid, but I can't see to keep around in IntPtr format. When I assign the IntPtr to a cell value, and then try to recast it as a pointer again, it bombs: _hWnd = (IntPtr)dgvTaskList.SelectedRows[0].Cells[2].Value; SetForegroundWindow(_hWnd); I need to either A) store a raw IntPtr in a cell (not as a string) B) be able to convert the string back to a ptr C) something else entirely that I'm not thinking of I'm open to any help or suggestions from my code project peers... Thanks! -- modified at 12:13 Tuesday 27th November, 2007

    S 1 Reply Last reply
    0
    • A alanteigne

      Hello, I'm writing a ALT+TAB-ish app that pops up due to a hotkey. It currently displays a list of currently running applications (using EnumWindows & GetWindowText) as a row in a DataGridView and I've created a event handler to run when a row is double clicked on. I'm hoping to use SetForeGroundWindow from User32.dll to bring the selected app to the front. This requires a pointer (IntPtr) to be passed, which I have available when populating my grid, but I can't see to keep around in IntPtr format. When I assign the IntPtr to a cell value, and then try to recast it as a pointer again, it bombs: _hWnd = (IntPtr)dgvTaskList.SelectedRows[0].Cells[2].Value; SetForegroundWindow(_hWnd); I need to either A) store a raw IntPtr in a cell (not as a string) B) be able to convert the string back to a ptr C) something else entirely that I'm not thinking of I'm open to any help or suggestions from my code project peers... Thanks! -- modified at 12:13 Tuesday 27th November, 2007

      S Offline
      S Offline
      Skippums
      wrote on last edited by
      #2

      how about... _hWnd = new IntPtr(int.Parse(dgvTaskList.SelectedRows[0].Cells[2].Value)); Jeff

      A 1 Reply Last reply
      0
      • S Skippums

        how about... _hWnd = new IntPtr(int.Parse(dgvTaskList.SelectedRows[0].Cells[2].Value)); Jeff

        A Offline
        A Offline
        alanteigne
        wrote on last edited by
        #3

        Holy cow man! _hWnd = new IntPtr(int.Parse(dgvTaskList.SelectedRows[0].Cells[2].Value.ToString())); ..worked. Thanks!

        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