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. .NET 4.7 Desktop Form combox coloring within datagridview

.NET 4.7 Desktop Form combox coloring within datagridview

Scheduled Pinned Locked Moved C#
csharp
3 Posts 2 Posters 2 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.
  • N Offline
    N Offline
    NET4Ever
    wrote on last edited by
    #1

    I can't find the setting(s) to change the color of a combobox within a datagridview. I tried this code below. I get a dark line around the datagridview cell and a white background. I see the colors I set below when I view the list within the combobox. combo.DisplayStyle = DataGridViewComboBoxDisplayStyle.ComboBox; combo.CellTemplate.Style.BackColor = Color.LightSalmon; combo.CellTemplate.Style.ForeColor = Color.Black; combo.CellTemplate.Style.SelectionBackColor = Color.LightSalmon; combo.CellTemplate.Style.SelectionForeColor = Color.Black;

    A 1 Reply Last reply
    0
    • N NET4Ever

      I can't find the setting(s) to change the color of a combobox within a datagridview. I tried this code below. I get a dark line around the datagridview cell and a white background. I see the colors I set below when I view the list within the combobox. combo.DisplayStyle = DataGridViewComboBoxDisplayStyle.ComboBox; combo.CellTemplate.Style.BackColor = Color.LightSalmon; combo.CellTemplate.Style.ForeColor = Color.Black; combo.CellTemplate.Style.SelectionBackColor = Color.LightSalmon; combo.CellTemplate.Style.SelectionForeColor = Color.Black;

      A Offline
      A Offline
      Alan N
      wrote on last edited by
      #2

      Microsoft have knobbled many features of quite a few controls (e.g. ProgressBar - we all prefer green! MonthCalendar - change the font to make it big enough to see - No!) and often the only thing you can do is to disable visual styles. That can be a problem though as some controls require visual styles to be on (e.g the Tile mode of the ListView). However with the DataGridView the colour works in the way you desire when the FlatStyle of the ComboBoxColumn is set to either FlatStyle.Flat or FlatStyle.Popup. I guess they missed that.

      N 1 Reply Last reply
      0
      • A Alan N

        Microsoft have knobbled many features of quite a few controls (e.g. ProgressBar - we all prefer green! MonthCalendar - change the font to make it big enough to see - No!) and often the only thing you can do is to disable visual styles. That can be a problem though as some controls require visual styles to be on (e.g the Tile mode of the ListView). However with the DataGridView the colour works in the way you desire when the FlatStyle of the ComboBoxColumn is set to either FlatStyle.Flat or FlatStyle.Popup. I guess they missed that.

        N Offline
        N Offline
        NET4Ever
        wrote on last edited by
        #3

        This worked. Thank you!

        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