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. currentcell backcolor

currentcell backcolor

Scheduled Pinned Locked Moved C#
helpquestion
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.
  • M Offline
    M Offline
    melanieab
    wrote on last edited by
    #1

    Hi, I have a datagrid & a datatable, and when I use the mousemove event, I run into trouble. private void dgMouseMove(object sender, System.Windows.Forms.MouseEventArgs e) { System.Windows.Forms.DataGrid.HitTestInfo hitInfo = dg.HitTest(new Point(e.X, e.Y)); ... // find out which cell is entered dg.CurrentCell = new DataGridCell(hitInfo.Row,hitInfo.Column); ... // use tooltip } The problem starts when I set dg.CurrentCell. Whatever it's set to, the backcolor of that cell changes to what looks like some default color (biege), and the text is highlighted. Also, the MouseUp event doesn't seem to fire, at least not consistently. I've been trying to figure this one out for a while now, and am pretty stuck. :confused: Anyone know what to do? You'd be my hero! Thanks, Mel

    V 1 Reply Last reply
    0
    • M melanieab

      Hi, I have a datagrid & a datatable, and when I use the mousemove event, I run into trouble. private void dgMouseMove(object sender, System.Windows.Forms.MouseEventArgs e) { System.Windows.Forms.DataGrid.HitTestInfo hitInfo = dg.HitTest(new Point(e.X, e.Y)); ... // find out which cell is entered dg.CurrentCell = new DataGridCell(hitInfo.Row,hitInfo.Column); ... // use tooltip } The problem starts when I set dg.CurrentCell. Whatever it's set to, the backcolor of that cell changes to what looks like some default color (biege), and the text is highlighted. Also, the MouseUp event doesn't seem to fire, at least not consistently. I've been trying to figure this one out for a while now, and am pretty stuck. :confused: Anyone know what to do? You'd be my hero! Thanks, Mel

      V Offline
      V Offline
      VPMahank
      wrote on last edited by
      #2

      It seems you are selecting a cell in the programmatically in the mousemove event by setting the CurrentCell. That is the reason its hightligting the cell with the default color and text is highlighted. Since there is not mouseDown happening here , mouseeUp would not be called. Why do you need to set the CurrentCell in the mousemove anyway? Thanks, VPMahank

      M 1 Reply Last reply
      0
      • V VPMahank

        It seems you are selecting a cell in the programmatically in the mousemove event by setting the CurrentCell. That is the reason its hightligting the cell with the default color and text is highlighted. Since there is not mouseDown happening here , mouseeUp would not be called. Why do you need to set the CurrentCell in the mousemove anyway? Thanks, VPMahank

        M Offline
        M Offline
        melanieab
        wrote on last edited by
        #3

        Hi! I use CurrentCell to get the text in the cell. private void dgMouseMove(object sender, System.Windows.Forms.MouseEventArgs e) { System.Windows.Forms.DataGrid.HitTestInfo hitInfo = dg.HitTest(new Point(e.X, e.Y)); if (hitInfo.Row < tCat.Rows.Count && hitInfo.Row > -1) { dg.CurrentCell = new DataGridCell(hitInfo.Row,hitInfo.Column); DataGridCell dc = dg.CurrentCell; string txt = dg[dc].ToString(); if (txt.Length > 10){ //tooltip stuff } } } There's one more case where I have this problem of a beige cell background and highlighted text - when I click on a cell (on MouseDown). As soon as the mouse comes back up, it goes back to the colors I want it to be. Is there any way to get rid of this? Thanks so much! Mel

        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