formatting the size text in datagridview

Ask questions about creating Graphical User Interfaces (GUI) in PowerShell and using WinForms controls.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 4 years and 9 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
jsira2003@yahoo.com
Posts: 117
Last visit: Tue Jul 11, 2023 6:18 am

formatting the size text in datagridview

Post by jsira2003@yahoo.com »

I was looking for the text sizing option control in datagridview. I could not find one. Is this possible? If so how?

thanks,
John
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: formatting the size text in datagridview

Post by jvierra »

You can set that in the cell properties in the designer. Use the "DefaultCellStyle" property.
User avatar
jsira2003@yahoo.com
Posts: 117
Last visit: Tue Jul 11, 2023 6:18 am

Re: formatting the size text in datagridview

Post by jsira2003@yahoo.com »

and if I don't use the designer and want a text command is it something like this?:

datagridviewtable.defaultcellstyle.font.size = "12"

thanks,
John
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: formatting the size text in datagridview

Post by jvierra »

No. You cannot set the size. You must create a font and set the "font" property to the new font.

Start by doing it in the designer and inspect the code that is produced to see how this is done.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: formatting the size text in datagridview

Post by jvierra »

When in doubt go to the documentation:

https://docs.microsoft.com/en-us/dotnet ... mework-4.8
User avatar
jsira2003@yahoo.com
Posts: 117
Last visit: Tue Jul 11, 2023 6:18 am

Re: formatting the size text in datagridview

Post by jsira2003@yahoo.com »

i used the cellstyle builder and it works fine. However when you save your program and re-open it, the cellstyle builder defaults back to the 14 point setting and I lose the font size I put in. In my view the cell style builder should maintain the font size I defined and I should not have to reset it in my datagridview with every build of my program.

I think this could be a bug!

John
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: formatting the size text in datagridview

Post by jvierra »

I can't reproduce your issue. If I set the property in the designer and build the script it has the font and color that I set.
This topic is 4 years and 9 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked