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.
Locked
User avatar
jsira2003@yahoo.com
Posts: 112
Meble kuchenne na zamówienie - na wymiar - Wrocław
Joined: Fri Apr 07, 2017 9:47 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: 14444
Joined: Tue May 22, 2007 9:57 am
Contact:

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: 112
Joined: Fri Apr 07, 2017 9:47 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: 14444
Joined: Tue May 22, 2007 9:57 am
Contact:

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: 14444
Joined: Tue May 22, 2007 9:57 am
Contact:

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: 112
Joined: Fri Apr 07, 2017 9:47 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: 14444
Joined: Tue May 22, 2007 9:57 am
Contact:

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.

Locked