So i need to make ICollection into a table, column width must be determined by max length of value of property. I currently use this
private static int GetWidth<T>(PropertyInfo prop, ICollection<T> source)
{
int width = 5;
foreach (var element in source)
{
if (prop.GetValue(element).ToString().Length > width)
{
width = prop.GetValue(element).ToString().Length;
}
}
return width;
}
but it does not work at all, maybe someone knows a way to do it? Edit: solved, used Math.Max(5, source.Max(e => prop.GetValue(e).ToString().Length)) instead
Aucun commentaire:
Enregistrer un commentaire