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 4 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.
pjbuckley wrote: ↑Tue Dec 10, 2019 4:43 pm
The value in the cell is an integer. The code is supposed to change the color of the cell based upon the value in the cell.
You cannot compare an integer to a string so try to break the habit. It will cause you issues forever. An integer cannot be quoted or it will become a string that contains the character value of the character
Try this at a prompt. [int]('0'[0])
This is what can happen in a comparison. Coercion will not work correctly under many circumstances especially when comparing to objects.
I am saying that you cannot quote a number in a comparison with an int. That is why I removed your quotes.
The code I posted does what you want assuming that the information you have provided is correct. Most of your code was not correct and was making incorrect assumptions.
The paint event is set once for each cell unt9il the paint cascade is complete. We detect the column which tells us the correct cell we want to target. The "$_" is the cell object that is passed to the event.
Thanks. I already reference those articles regularly. they are useful but havent helped me fix my problem.
I learn by working examples. I take bits of code that work and apply them to my scripts.
Since that is all in C# its mostly gobbledy-gook to me. i dont have a background in development and dont develop every day for my job. This is a one off that i need to get done because i am already WAY over budget and losing money every day i cant get these (apparently) simple tasks in a much bigger project done.
I didn't put them up for reference. You need to read the full article carefully and review the code and what it is showing you.
It is clear that you haven't learned how to use the documentation and you haven't read the doc on the event. You need to do this to understand how to use forms. That is why Sapien links these articles to the control in the toolbox. Just click on the control then find the event and read the details of the args and usage.
The code I posted is how the event is intended to work. If you do not understand why I changed your code in the way I did then you need to read the docs until you understand.
You cannot get working examples that are usable anywhere except for very trivial issues. The docs on the "Graphics" object and events must be studied and learned. There are no good examples If I had the time I would write a documented example but that would take about 10 pages and would assume a basic understanding of forms, controls and events at a technical level as well as Windows and the Windows Graphics system as exposed by the "System.Drawing" namespace and the "System.Drawing.Graphics" namespace and other namespaces that are used by the WinForms system.
This topic is 4 years and 4 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.