Expand DataGridView columns to 100% Width RRS feed

  • Question


    Hi.  Is it possible to expand DataGridView columns to fill 100% (horizontally) of the control?  Currently my columns size dynamically based on the size of the data, but I want the columns to always take up 100% width.


    Is that possible?


    Tuesday, December 9, 2008 10:22 PM




    Hi Gacutil,


    You can set AutoSizeColumnsMode property of the dataGridView  to  Fill , or use the following code .


    Code Snippet

    this.dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;


    Best regards,
    • Proposed as answer by Steven.Yu Monday, December 15, 2008 3:33 AM
    • Marked as answer by Steven.Yu Monday, December 22, 2008 6:49 AM
    Wednesday, December 10, 2008 8:33 AM