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. Fill datagridview cell with color

Fill datagridview cell with color

Scheduled Pinned Locked Moved C#
question
5 Posts 3 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.
  • P Offline
    P Offline
    perry59
    wrote on last edited by
    #1

    I want to fill the cells of a datagridview column based on numbers derived at runtime. Sounds easy enough but... these two lines of code work great if I only wanted red dataGridView1.Rows[layerCount].Cells[3].Style.BackColor = Color.Red; dataGridView1.Rows[layerCount].Cells[3].Style.ForeColor = Color.Red; but these two lines just color the cells text (if existing)? or they just act bizzarly(although they worked good with a listview) dataGridView1.Rows[layerCount].Cells[3].Style.BackColor = Color.FromArgb(swLayer.Color); dataGridView1.Rows[layerCount].Cells[3].Style.ForeColor = Color.FromArgb(swLayer.Color); Anyone have any pointer? wait a minute, no POINTERS, how about advice :)

    L P 2 Replies Last reply
    0
    • P perry59

      I want to fill the cells of a datagridview column based on numbers derived at runtime. Sounds easy enough but... these two lines of code work great if I only wanted red dataGridView1.Rows[layerCount].Cells[3].Style.BackColor = Color.Red; dataGridView1.Rows[layerCount].Cells[3].Style.ForeColor = Color.Red; but these two lines just color the cells text (if existing)? or they just act bizzarly(although they worked good with a listview) dataGridView1.Rows[layerCount].Cells[3].Style.BackColor = Color.FromArgb(swLayer.Color); dataGridView1.Rows[layerCount].Cells[3].Style.ForeColor = Color.FromArgb(swLayer.Color); Anyone have any pointer? wait a minute, no POINTERS, how about advice :)

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      My CP Vanity article fills DGV cells with platinum, gold, silver, bronze. No problem, unless the cell is otherwise empty, then it may get tricky. :)

      Luc Pattyn [My Articles] Nil Volentibus Arduum

      M 1 Reply Last reply
      0
      • L Luc Pattyn

        My CP Vanity article fills DGV cells with platinum, gold, silver, bronze. No problem, unless the cell is otherwise empty, then it may get tricky. :)

        Luc Pattyn [My Articles] Nil Volentibus Arduum

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

        what is CP vanity.?? where is code?

        L 1 Reply Last reply
        0
        • M MahaKh

          what is CP vanity.?? where is code?

          L Offline
          L Offline
          Luc Pattyn
          wrote on last edited by
          #4

          It is one of my articles, as I said. And it has a download link. :)

          Luc Pattyn [My Articles] Nil Volentibus Arduum

          1 Reply Last reply
          0
          • P perry59

            I want to fill the cells of a datagridview column based on numbers derived at runtime. Sounds easy enough but... these two lines of code work great if I only wanted red dataGridView1.Rows[layerCount].Cells[3].Style.BackColor = Color.Red; dataGridView1.Rows[layerCount].Cells[3].Style.ForeColor = Color.Red; but these two lines just color the cells text (if existing)? or they just act bizzarly(although they worked good with a listview) dataGridView1.Rows[layerCount].Cells[3].Style.BackColor = Color.FromArgb(swLayer.Color); dataGridView1.Rows[layerCount].Cells[3].Style.ForeColor = Color.FromArgb(swLayer.Color); Anyone have any pointer? wait a minute, no POINTERS, how about advice :)

            P Offline
            P Offline
            perry59
            wrote on last edited by
            #5

            I found an answer. Using System.Drawing.ColorTranslator.FromWin32() instead of ArgB();

            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