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. Dynamically change Row.ForeColor

Dynamically change Row.ForeColor

Scheduled Pinned Locked Moved C#
csharpcsstutorialquestion
6 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.
  • E Offline
    E Offline
    e_LA
    wrote on last edited by
    #1

    Hi I work with Framework 2.0 (c#). I do not know how to dynamicaly change ForeColor of a row in DataGridView depending on value of one column in grid which changes dynamically too. When I tried to use DataGridView.CellFormatting event only cell where the value is changed has the right forecolor. However other have the old one. After selecting and deselecting other cells in the row they have right color. AlternatingStyle is not good because there are more than two kind of colors. Which event do I have to use and which method call in order to refresh a whole row? Before (in Framework 1.1) I did it by creating columns inheriting from my own class where method paint was overriden. However I would like to use new features in F 2.0. Thanks Ela

    N 1 Reply Last reply
    0
    • E e_LA

      Hi I work with Framework 2.0 (c#). I do not know how to dynamicaly change ForeColor of a row in DataGridView depending on value of one column in grid which changes dynamically too. When I tried to use DataGridView.CellFormatting event only cell where the value is changed has the right forecolor. However other have the old one. After selecting and deselecting other cells in the row they have right color. AlternatingStyle is not good because there are more than two kind of colors. Which event do I have to use and which method call in order to refresh a whole row? Before (in Framework 1.1) I did it by creating columns inheriting from my own class where method paint was overriden. However I would like to use new features in F 2.0. Thanks Ela

      N Offline
      N Offline
      Not Active
      wrote on last edited by
      #2

      e_LA wrote:

      When I tried to use DataGridView.CellFormatting event only cell where the value is changed has the right forecolor

      I think you're close. You can get the rowindex from this event and change the cells in the row.

      only two letters away from being an asset

      E 3 Replies Last reply
      0
      • N Not Active

        e_LA wrote:

        When I tried to use DataGridView.CellFormatting event only cell where the value is changed has the right forecolor

        I think you're close. You can get the rowindex from this event and change the cells in the row.

        only two letters away from being an asset

        E Offline
        E Offline
        e_LA
        wrote on last edited by
        #3

        Sorry but I do not understand. Move to others cells?

        1 Reply Last reply
        0
        • N Not Active

          e_LA wrote:

          When I tried to use DataGridView.CellFormatting event only cell where the value is changed has the right forecolor

          I think you're close. You can get the rowindex from this event and change the cells in the row.

          only two letters away from being an asset

          E Offline
          E Offline
          e_LA
          wrote on last edited by
          #4

          I did something like that in formattingCellEvent myDataGridView.Rows[e.RowIndex].Cells[5].Style.ForeColor = e.CellStyle.ForeColor; Just fifth cell for example .... and now it works ....very strange

          1 Reply Last reply
          0
          • N Not Active

            e_LA wrote:

            When I tried to use DataGridView.CellFormatting event only cell where the value is changed has the right forecolor

            I think you're close. You can get the rowindex from this event and change the cells in the row.

            only two letters away from being an asset

            E Offline
            E Offline
            e_LA
            wrote on last edited by
            #5

            It doesn't work if I stay in the same row (I do not change the row) - for example by pressing TAB not ENTER. I think I should return to the previous version with overriding Paint event in custom type column :-(

            N 1 Reply Last reply
            0
            • E e_LA

              It doesn't work if I stay in the same row (I do not change the row) - for example by pressing TAB not ENTER. I think I should return to the previous version with overriding Paint event in custom type column :-(

              N Offline
              N Offline
              Not Active
              wrote on last edited by
              #6

              I don't understand what you are trying to do and what you are doing. Maybe a code snippet would be helpful. Once you change the color of a cell it doesn't matter what else you do.

              only two letters away from being an asset

              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