i have a grid and i accessing each unique column via its name like so:
grid.Columns["SomeColumnA"]
however i can only set the properties of that column if it is not null like so:
if (grid.Columns["SomeColumnB"] != null) {
grid.Columns["SomeColumnB"].Width = 100;
}
i have about 15/20 different columns which need to be set for various things but they all need to be checked for null first. It looks a bit messy as its 15/20 if statements. I am thinking whether or not these if statements are the best way or can i implement something else to simplify it and tidy the code up. Any ideas/suggestions please?
Aucun commentaire:
Enregistrer un commentaire