开发者

max number of columns on a DataGridView

We need a datagridview with more than 2000 columns.

The problem that we have is that only around 700 columns are showing correctly, and the remaining are not showing.

We need to do this because each column represents a day for example开发者_高级运维: 2009/01/01/ - 2009/01/02

Does this control have a limit of columns that can show correctly?

Using VS 2010.


Yes, I think there's limitation in the count of columns in DataGridView, check this

I suggest implement it like the calender in Outlook.

Good luck.


The maximum number of columns you can add is 654. This is based on the demo application which I created to check the maximum number of columns.

Steps:

  1. Create a Windows Forms Application project in C#.
  2. Add a Window From named "Test" in your project.
  3. Drag and drop a DataGridView control on your windows form.
  4. On Load event of the windows form write the following code:
  5. Execute the the application (F5) and see the number of columns.

             try
                {
                    for (int i = 0; i < 1000; i++)
                    {
                        dataGridView1.Columns.Add(i.ToString(), i.ToString());
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message.ToString());
                }
    


The maximum number of columns you can add is 654

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜