I have a datagridview table that I need to display some data in. In certain instances, I exceed the column number limit and get the following error:
Sum of the columns' FillWeight values cannot exceed 65535
Is there any other tool that I could use to overcome this constraint?
Solution 1Use the MaxInputLength property of the DataGridViewTextBoxColumn.
FILL WEIGHT shall refer to the weight of a cooked tuna Loin portion that is placed in each can prior to the addition of water and/or Hydrolyzed Protein, and prior to the sealing of the can.
Open a grid event columnAdded
.
private void dataGridViewName_ColumnAdded(object sender, DataGridViewColumnEventArgs e)
{
e.Column.FillWeight = 10; // <<this line will help you
}
The default fill weight for a column in the DataGridView is 100. This combined with the maximun combined fill weight for the grid of 65535 means that with AutoGenerateColumns
set to true you cannot have more than 655 columns in your data source.
If you need more columns than this then the only solution is to set AutoGenerateColumns
for the grid to false, and then manually add the columns with a different fill weight (I'm not sure if 0 is a valid fill weight, so you may need to use 1).
It might be worth your while considering a different design - having so many columns in a DataGridView won't be very usable, the performance of the DataGridView is only tuned for up to 100 columns (I got that figure from this forum post by the DataGridView program manager)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With