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 2 years and 2 weeks 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.
I have created a Datagridview with columns that are combo boxes. Each column dependent on each other for data in the row. for example. When populate column 0 it will then populate column 1 then what ever is in column 1 will populate column 2. Also when I click on the first row it automatically makes another row of combo boxes. Which is ok cause that is what I want. But when I fill the first row I am ok when got to fill the second row I have an issue and get the error attached. I don't know maybe the event I am using is in correct.
With that being said I don't know if I am doing this right.
The error is clear. The underlying data type does not match the requested operation.
I recommend running in the debugger and finding the exact line and data types. Without that as a minimum the error is mostly useless. Note that any column that contains a null in the database can throw his exception.
sekou2331 wrote: ↑Wed Mar 30, 2022 8:14 am
It looks like when I go to the next row I am unable to populate it correct it will populate the one above instead of the on I am on.
What does this have to do with your original issue? If you add multiple unrelated issues it only makes it harder to understand what you are asking.
When I am adding this line I am running into the attached error. I ran debug and soon as I use the Value change event the error comes and Powershell studio does not give me anything. When I kill it I get nothing as well.
2022-03-31 17_50_51-insert.png (11.49 KiB) Viewed 1212 times
You are trying to assign an array to a "cell collection". An array is not a DataGridViewCellCollection type. The "array" is not a type either it is just a token that has no meaning. It is not even a variable.
I recommend starting by learning basic PowerShell instead of just guessing. When you learn PowerShell, you will learn how to read exceptions and errors. You will also learn about "types", "type coercion". You will also learn the syntax elements and the correct method of defining strings and variables as well as how to work with collections.
Note that almost any time a property of an object ends in an "s" it indicates that it is a collection of some kind. If you inspect the property in the debugger, it will tell you that it is a DataGridViewCellCollection type. Look up the type on the MS site to learn how the type is designed with examples of how it can be used.
Ok I understand but even if I do the below it is the same error. Also I was using a combo box for the cell I even tired the DropDownButton which both should except an array. I am using a row of DropDownButtons so that the user can choose from an array of string for each cell. I will read what you have given me.
This topic is 2 years and 2 weeks 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.