Formatting cells of a DataGridView best place for the code?

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 7 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
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Formatting cells of a DataGridView best place for the code?

Post by jvierra »

Very nice. You don't need some of the code.

This does what you are trying to do:

If ($this.Columns[$_.ColumnIndex].Name -eq 'ARTIST') {

"-eq" is case insensitive and behaves better then the object method. Be careful with that when using C# code for an example. Much of what we can do easily in PowerShell cannot be done in C#.
User avatar
DrewEaston
Posts: 48
Last visit: Thu Mar 30, 2023 8:47 am

Re: Formatting cells of a DataGridView best place for the code?

Post by DrewEaston »

Hi jvierra,

Thanks again that experience that you are share is the value of GOLD.
I will use that, that a somewhat of a habit coming from VBS I have not programmed in C# and I have not programmed in C since 2002. Mainly java and other languages.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Formatting cells of a DataGridView best place for the code?

Post by jvierra »

There is only one good book on programming with Windows Forms and it is in C#/VB.Net. It is still very useful. Once you see how to map PS onto C# examples then Forms are very easy. WPF is more powerful but much harder to work with.
This topic is 4 years and 7 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