I am in the process of creating a form in order to make it easier for me to update a .ini file. I have been able to get the form to generate correctly but have been unable to figure out how to output the values from the comboboxes and textboxes created by the ForEach loop after I have made changes. Is there a way to have the loop assign a variable or some other way to refer back to each of them as they are created? Below is the loop I am currently working with.
Without having any experience with GUIs the following code looks - at least - ununsual to me.
ForEach ($value in $valuearraylist) {
if ( $_ -eq "TRUE" -or $_ -eq "FALSE") {
Why is it $_ and not $Value in your if statement?
And why do you check for $_ to be trueORfalse? Shouldn’t that be only one of it? And shouldn’t it be $true instead of TRUE or $false instead of FALSE?
And why don’t you reference the loop variable $value at leaset once in your loop?
which is why I was using $_ but yes, I will change it to $value now.
As for what the $valuearraylist contains, it is all plain text. For the lines that contain TRUE or FALSE, I wanted it to create a combobox, so I had one block check for both values and create a TRUE or FALSE combobox. The rest of the lines are plain text that would be easiest to change using a textbox which is what this loop does.
I just have not been able to find any way to make each individual combobox and textbox callable outside the loop so that I can output all the values after I have made changes.
That sounds like a weird way of providing values for different purposses. You may consider using another file type for your configuration such as CSV, XML, PSD1, YAML or JSON.
Regardless of that you may share all or at least the relevant part of your code. I’m pretty sure we have some forum members with enough experiences with GUIs to be able to help you further.
In general it is better to limit the code you share to a “minimal reproducable example” but if it’s needed to understand your issue you may post it completely anyway.
I am satisfied with my data input, it is just being able to call back to each box the loop creates that I am having trouble figuring out. I honestly don’t even know if it is possible to do.
Not sure I understand what you mean by callable, but I have a script that loads a windows form, does a bunch of stuff via user interaction on the form, then when they close the form, the main script continues. I did that by putting the form creation and load in a function. Then, in the main body of the script, I call the function, the user does their thing on the form, they close the form and the script moves on. Have you tried something like that?
The code I shared creates the Value column and after I make changes to those boxes, I want to be able to get the new values to output to file. If there is a better way to do this, I am all ears and happy to try it.