How to increase datagrid limitation of columns

Srikant S 46 Reputation points
2020-09-20T05:57:07.787+00:00

HI Team,

I have one project were i want to use N*N matrix form, now when i enter more then 700 columns limits it gives error as it has range from o to 65335, what the soultion were i can use more then 750 columns.

Windows Forms
Windows Forms
A set of .NET Framework managed libraries for developing graphical user interfaces.
1,869 questions
{count} votes

Accepted answer
  1. Daniel Zhang-MSFT 9,621 Reputation points
    2020-09-21T02:25:54.463+00:00

    Hi Srikant S,
    By default, the FillWeight property of the datagridviewcolumn is set to 100. This can only provide up to 655 columns.
    If you want to impose a lower limit on the maximum number of columns, you can use a value of FillWeight greater than 1.
    So you can set the FillWeight property to 1 in ColumnAdded event to get more columns.
    Here is a simple code example.

    private void dataGridView1_ColumnAdded(object sender, DataGridViewColumnEventArgs e)  
    {  
        e.Column.FillWeight = 1;  
    }  
    

    Best Regards,
    Daniel Zhang


    If the response is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

0 additional answers

Sort by: Most helpful