code optimisation

hi,

My application require the following piece of code to be executed to acheive the desired functionality.
The average value for dgRangePlanGrid.TableDescriptor.Columns.Count is 300 and its taking around 8 seconds to execute this code..
Can you help me in optimising this code.
One more thing is that in my out put window, when i debug the application, i get the following message.

"Could not find Field with name in EntityCollectionView`1 for column Column 1". Can that be the reason for the long time taken. If yes, waht can be the resolution.



for (int i = 0; i < dgRangePlanGrid.TableDescriptor.Columns.Count; i++)
{
viewColumnName = dgRangePlanGrid.TableDescriptor.Columns[i].Name;

if (!dgRangePlanGrid.TableDescriptor.VisibleColumns.Contains(viewColumnName))
{
dgRangePlanGrid.TableDescriptor.VisibleColumns.Add(viewColumnName);
dgRangePlanGrid.TableDescriptor.Relations[Constants.SUPPLIERFACTORY_RELATION].ChildTableDescriptor.VisibleColumns.Add(viewColumnName);

if (viewColumnName == "StatusCancelled")
{
dgRangePlanGrid.TableDescriptor.Columns[viewColumnName].Width = 50;
dgRangePlanGrid.TableDescriptor.Relations[Constants.SUPPLIERFACTORY_RELATION].ChildTableDescriptor.Columns[viewColumnName].Width = 50;
}
else
{
dgRangePlanGrid.TableDescriptor.Columns[viewColumnName].Width = 0;
dgRangePlanGrid.TableDescriptor.Relations[Constants.SUPPLIERFACTORY_RELATION].ChildTableDescriptor.Columns[viewColumnName].Width = 0;
}
}
}

Loader.
Up arrow icon