is it possible to search a particular setter, rather than iterating through the collection and doing something like this.
foreach (Setter setter in dataRecord.Cells[i].Field.Settings.EditorStyle.Setters)
{
if (setter.Property.Name == "Format")
{
excelWorkSheetRow.Cells[i + level].CellFormat.FormatString = setter.Value.ToString();
break;
}
}
The SetterBaseCollection doesn’t provide any methods beyond those inherited from Collection<>. You can use the FindFirstOrDefault extension method to retrieve the setter you want like this:
The trick is that SetterBaseCollection can contain both Setter and EventSetter object. Only Setter objects have the Property … property, so you need OfType<> to search only the Setter objects. Your code would break if anyone ever added an event setter to the style.