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 6688373
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:23:51+00:00 2026-05-26T05:23:51+00:00

I have a column that holds Checkboxes. My main problem is that when I

  • 0

I have a column that holds Checkboxes.

My main problem is that when I call this function:

dataGrid.AutoResizeColumn(0, DataGridViewAutoSizeColumnMode.DisplayedCells);  

It stretches the checkbox column too, and I want that column to stay in 25 in width.

How can I do that? (only checkbox column not stretched)


Here is some more code, showing what I want to happen:

dataGrid.AutoResizeColumn(0, DataGridViewAutoSizeColumnMode.DisplayedCells);
dataGrid.AutoResizeColumn(1, DataGridViewAutoSizeColumnMode.Fill); 
dataGrid.AutoResizeColumn(2, DataGridViewAutoSizeColumnMode.Fill); 
dataGrid.AutoResizeColumn(3, DataGridViewAutoSizeColumnMode.DisplayedCells);
dataGrid.AutoResizeColumn(4, DataGridViewAutoSizeColumnMode.Fill); 
dataGrid.AutoResizeColumn(5, DataGridViewAutoSizeColumnMode.Fill); 

But the fill gives me an error.

  • 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-26T05:23:52+00:00Added an answer on May 26, 2026 at 5:23 am

    What you are asking doesn’t quite make sense, since the method you show AutoResizeColumn take as its first parameter the column index to resize – if you call this method with the index of the checkbox column then your are explicitly telling the grid to resize that column. If you don’t want the resize, don’t do that!

    If you set the resize mode the next level up for the grid, you do it like this:

    dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.DisplayedCells;
    

    Now with this method of setting the sizing mode then yes, the checkbox will change when you might want it to.

    The answer to that is to use either the designer or the method you mention above, and set the checkbox columns autosize mode to None

    If you absolutely must loop over the columns setting their AutoResize mode, then the only option you have is to check if you have the checkbox column in the loop and apply a different more.


    This is in answer to your comment – the error you will be seeing is an ArgumentException being thrown by the AutoResizeColumn method. This is all documented on the MSDN page for the AutoResizeColumn method. You cannot specify a AutoSize mode of None or Fill.

    It sounds like what you want to do is something like:

    // If column 3 is the checkbox column, we set its resize mode to none:
    dataGridView1.Columns[3].AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
    // Then we set the width:
    dataGridView1.Columns[3].Width = 25;
    // Finally we set the rest of the grid to fill or what ever resizing you need:
    dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Lets suppose that I have a Category table with a column that holds the
I have a database column WantsReply that logically holds a boolean (bit) but is
I have column that contains strings. The strings in that column look like this:
I have a column that contains links. The problem is that the titles of
I have a column called THE_VALUE in a table TABLE_A , that holds data
I have an xml column ExportTemplate in a table that holds an xsl template
I have on my database a column that holds text in RTF format. How
I have a column in mssql table that holds numbers 1 thru 101. Using
I have a column that holds the genre of a movie (up to three
I have an integer column that holds a Unix epoch time value. I want

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.