Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
What's Wrong With This Code?
Message
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Divers
Thread ID:
01386784
Message ID:
01386813
Vues:
51
>I have a grid which displays a checkbook register. The total width of all the columns is less than the total width of the grid, so I want to resize the TransDesc column to fill it in:
>
>
>int iColumnWidths = 0;
>foreach (DataGridViewColumn oCol in grdRegister.Columns)
>{
>    iColumnWidths = iColumnWidths + oCol.Width;
>}
>grdRegister.Columns["TransDesc"].Width = grdRegister.Width - iColumnWidths;
>
>
>The TransDesc.Width value is negative.

Is TransDesc column part of the grdRegister.Columns? If yes, it's included into the calculation and then, of course, the width would become negative. You need to exclude if with if code from the loop.
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform