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

  • Home
  • SEARCH
  • 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 8661271
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T16:27:26+00:00 2026-06-12T16:27:26+00:00

In my DataGridView, there’s a small tick mark which helps the user visualize which

  • 0

In my DataGridView, there’s a small tick mark which helps the user visualize which row they’re in but there doesn’t seem to be the same kind of tick mark for the current column that they’re in.

enter image description here

  • 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-06-12T16:27:27+00:00Added an answer on June 12, 2026 at 4:27 pm

    If you want an actual tic mark, you will either need to do some custom drawing, or manipulate the sorting tic mark. I don;t recommend the latter, because it is by now a convention that the little arrow in a column header means “sort.”

    You can, however, play with the formatting of the header cell. In this (semi-crude, but effective) example, a change the text in the header cell to bold to indicate the column in which the currently selected cell resides. When the user changes cells, either by tabbing or by simply clicking into a new cell, the correct column header text changes to bold.

    enter image description here

    Obviously, there are some other properties to mess with, although you may have to fiddle about for a while trying to find the proper ways to use the style property. I used the bold text because it was an easy demo (it is probably how I would approach it in a project, as well however).

    Basically, it all comes down to the DataGridViewColumn.HeaderCell.Style property.

    In the following, I inherit from the DataGridview class, and then use some event handling to manipulate the header cell during the CellEnter event sourced by the control:

    class dgvControl : DataGridView
    {
        // Keep track of the most recently selected column:
        private DataGridViewColumn _currentColumn;
    
        public dgvControl() : base()
        {
            // Add a handler for the cell enter event:
            this.CellEnter += new DataGridViewCellEventHandler(dgvControl_CellEnter);
    
            // When the Control is initialized, instantiate the placeholder
            // variable as a new object:
            _currentColumn = new DataGridViewColumn();
    
            // In case there are no columns added (for the designer):
            if (this.Columns.Count > 0)
            {
                this.OnColumnFocus(0);
            }
        }
    
    
        void dgvControl_CellEnter(object sender, DataGridViewCellEventArgs e)
        {
            this.OnColumnFocus(e.ColumnIndex);        
        }
    
    
        void OnColumnFocus(int ColumnIndex)
        {
            // If the new cell is in the same column, do nothing:
            if (ColumnIndex != _currentColumn.Index)
            {
                // Set up a custom font to represent the current column:
                Font selectedFont = new Font(this.Font, FontStyle.Bold);
    
                // Grab a reference to the current column:
                var newColumn = this.Columns[ColumnIndex];
    
                // Change the font to indicate status:
                newColumn.HeaderCell.Style.Font = selectedFont;
    
                // Set the font of the previous column back to normal:
                _currentColumn.HeaderCell.Style.Font = this.Font;
    
                // Set the current column placeholder to refer to the new column:
                _currentColumn = newColumn;
            }
    
        }
    }
    

    UPDATE:

    If you want to take more control, and mess with the header cell back color or other style properties other than the font, you will need to set the EnableHeadersVisualStyles property to false. The code below has been modified such that the background color of the header can be manipulated. The price for the increased flexibility is that you no longer get the somewhat slicker visual appearance of the headers (they flatten out, and no longer have the slight gradient).

    You can be really ambitious and override the OnPaint method to do your own draing, but that seems a bit extreme. Try this code, see if the appearance of the headers is simply inbearable. Anyway, it’s a start!

    class dgvControl : DataGridView
    {
        // Keep track of the most recently selected column:
        private DataGridViewColumn _currentColumn;
    
        public dgvControl() : base()
        {
            this.EnableHeadersVisualStyles = false;
    
            // Add a handler for the cell enter event:
            this.CellEnter += new DataGridViewCellEventHandler(dgvControl_CellEnter);
    
            // When the Control is initialized, instantiate the placeholder
            // variable as a new object:
            _currentColumn = new DataGridViewColumn();
    
            // In case there are no columns added (for the designer):
            if (this.Columns.Count > 0)
            {
                this.OnColumnFocus(0);
            }
        }
    
    
        void dgvControl_CellEnter(object sender, DataGridViewCellEventArgs e)
        {
            this.OnColumnFocus(e.ColumnIndex);        
        }
    
    
        void OnColumnFocus(int ColumnIndex)
        {
            // If the new cell is in the same column, do nothing:
            if (ColumnIndex != _currentColumn.Index)
            {
                // Set up a custom font to represent the current column:
                Font selectedFont = new Font(this.Font, FontStyle.Bold);
    
                // Grab a reference to the current column:
                var newColumn = this.Columns[ColumnIndex];
    
                // Change the font to indicate status:
                newColumn.HeaderCell.Style.Font = selectedFont;
    
                // Change the color to a slightly darker shade of gray:
                newColumn.HeaderCell.Style.BackColor = Color.LightGray;
    
    
                // Set the font of the previous column back to normal:
                _currentColumn.HeaderCell.Style.Font = this.Font;
    
                // Change the color of the previous column back to the default:
                _currentColumn.HeaderCell.Style.BackColor = Color.Empty;
    
    
                // Set the current column placeholder to refer to the new column:
                _currentColumn = newColumn;
            }
    
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a way to add a column footer in a datagridview which is
I am using a datagridview to get the IP address from user. Is there
I've done this before with a DataGridView , but is there some way to
1. I am using a DataGridView, which is bound to a dataset. There is
is there a way to cast/convert the currently selected Row in a datagridview to
I have a datagridview with a bound combobox column which contains decimal value. There
Suppose there are n buttons and one datagridview. I drag a dataset which contains
I have datagridview which fills data from database, there are columns where I have
I have a DataGridview in which there is a DataTimePickerColumn , and it's DateTimePickerCell
When I fill a DataGridView with data, there is always an empty row at

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.