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.
jvierra
Posts: 13992
Joined: Tue May 22, 2007 9:57 am
Contact:

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

Post by jvierra » Wed Aug 07, 2019 11:40 am

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
Joined: Mon Mar 12, 2007 4:43 pm

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

Post by DrewEaston » Thu Aug 08, 2019 9:49 am

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

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

Post by jvierra » Thu Aug 08, 2019 11:05 am

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.

Locked