© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
41 replies
SWEETPONY

✅ How to change of property without setter?

I have
ObjectCollection
ObjectCollection
with different objects:
TableCell
TableCell
,
TextObject
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);               
}  
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 = ..
((reportObjects[i] as TableCell)! ).Font.Name = ..
but
Name
Name
is doesn't have any setter.
So what to do? I wanna change only font name
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Property setter disappears on `PublishTrimmed`
C#CC# / help
11mo ago
✅ Override (abstract) getter-only property with a setter
C#CC# / help
3y ago
✅ How to change property in tree-like objects?
C#CC# / help
3y ago
Avalonia UI Unable to find suitable setter or adder for property Styles
C#CC# / help
2y ago