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. Visual Basic
  4. Where to update datagrid cells

Where to update datagrid cells

Scheduled Pinned Locked Moved Visual Basic
questionannouncement
3 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.
  • R Offline
    R Offline
    RudyVB68
    wrote on last edited by
    #1

    Hello, So I have some code to change the color of a cell on a datagridview. If e.Value.ToString.Length > 0 Then e.CellStyle.BackColor = Color.Blue e.CellStyle.ForeColor = Color.White End If Where is the best place to put this, cell formatting or cell painting. Or is there a better place? Thanks! Rudy

    S 1 Reply Last reply
    0
    • R RudyVB68

      Hello, So I have some code to change the color of a cell on a datagridview. If e.Value.ToString.Length > 0 Then e.CellStyle.BackColor = Color.Blue e.CellStyle.ForeColor = Color.White End If Where is the best place to put this, cell formatting or cell painting. Or is there a better place? Thanks! Rudy

      S Offline
      S Offline
      Suresh Suthar
      wrote on last edited by
      #2

      CellFormatting event is better to handle this type of customized formatting. Have a look at this... http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview.cellformatting.aspx[^]

      The man who makes no mistakes does not usually make anything. ~Edward Phelps Man's wisest mistake: Marriage. ~ Suresh Suthar

      L 1 Reply Last reply
      0
      • S Suresh Suthar

        CellFormatting event is better to handle this type of customized formatting. Have a look at this... http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview.cellformatting.aspx[^]

        The man who makes no mistakes does not usually make anything. ~Edward Phelps Man's wisest mistake: Marriage. ~ Suresh Suthar

        L Offline
        L Offline
        LCARS x32
        wrote on last edited by
        #3

        Cellformatting is where you want it. You were close. Just add another line under your code to change the color:

        e.FormattingApplied = True

        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