C#C
C#3y ago
SWEETPONY

✅ How to change of property without setter?

I have ObjectCollection with different objects: TableCell, TextObject etc.

What I want: find TableCell, TextObject adn change their font family name.
I did following:
var reportObjects = _report.AllObjects;
for (var i = 0; i < reportObjects.Count; i++)                                                 
{                                                                                               
    if (reportObjects[i] is TableCell)                                                      
        ((reportObjects[i] as TableCell)!).Font = new Font("Calibri", 20);                
    if (reportObjects[i] is TextObject)                                                     
        ((reportObjects[i] as TextObject)!).Font = new Font("Calibri", 20);               
}  


my code change full font now but I don't need this because I don't wanna change original font size!

I can do smth like this.. ((reportObjects[i] as TableCell)! ).Font.Name = .. but Name is doesn't have any setter.
So what to do? I wanna change only font name
Was this page helpful?