Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1067803
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T20:12:19+00:00 2026-05-16T20:12:19+00:00

I have a DataGridView bound to a list of objects, and I’m setting a

  • 0

I have a DataGridView bound to a list of objects, and I’m setting a dynamic cell background colour using the CellFormatting event, as in this answer. This works well for every column except the DataGridViewCheckboxColumn. When I click inside this cell (but outside the checkbox) the cell background changes to the default white.

Visually it looks like cell selection is occurring, despite my best efforts to stop it. My cell formatting code sets the SelectionBackColor as well as the BackColor. I’ve disabled cell selection using the CellStateChanged event, and none of the other columns are selectable:

private void PlayerGrid_CellStateChanged(object sender, DataGridViewCellStateChangedEventArgs e)
{
    if (e.StateChanged == DataGridViewElementStates.Selected)
       e.Cell.Selected = false;
}

Is there an extra workaround to override the cell behaviour for checkboxes?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T20:12:20+00:00Added an answer on May 16, 2026 at 8:12 pm

    I’ve found a workaround by adding the following code to the CellStateChanged event:

    if (e.Cell is DataGridViewCheckBoxCell)
          e.Cell.Style.BackColor = BackgroundColor(e.Cell.RowIndex);
    

    (BackgroundColor() calculates the cell background colour based on the row.)

    This cures the problem, but could cause performance issues for larger or virtual tables, by causing creation of extra style objects.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have a DataGridView bound to a LIST that contains 4 fields. The
I have a datagridview bound to a bindingsource. Two of the columns contain values
I have a c# winform application (2008) with datagridview bound to data from sqlserver.
I have a datagridview on a form that is bound to a table in
A relatively simple question. I have a datagridview, which all it does is displays
I have the following business object: public class MyObject { // Some public properties
I have a problem and I can't seem to be able to solve it.
I've a very trivial requirement which makes me go nuts. I've a DataGridView in
I've searched for an example of sorting a DataGridView on multiple columns, but don't
I'm pretty new to ORMs, and I'm currently giving Telerik OpenAccess ORM a try

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.