how do i utilize datagridview data as input for a script

Welcome Forums General PowerShell Q&A how do i utilize datagridview data as input for a script

This topic contains 2 replies, has 2 voices, and was last updated by

2 years, 9 months ago.

  • Author
  • #35525

    Points: 14
    Rank: Member

    i know this is probably really basic, but can't seem to find an easy answer on any searches.

    i want to utilize a datagridview object as input for a script.

    i can build up a datagridview, that is manually filled in by the users, however, once that is populated i can't find anywhere that describes straightforward now to loop through the contents, and how to extract the cells to use as variables elsewhere in the script.

  • #35526

    Points: 1,638
    Helping HandTeam Member
    Rank: Community Hero

    Really more of a .NET Framework question, not so much PowerShell. I used as a tutorial (which admittedly I originally found by Googling "datagridview tutorial") and adapted it from C#. But the DGV is really designed to be linked to a database so edits can be submitted to the back-end. You might also see if is helpful. Honestly, StackOverflow is going to be a better source for you on this, since it's all .NET.

    I'll venture the opinion that PowerShell isn't the awesome-most GUI development environment. You might be happier in Visual Studio with C#, for example, if you're serious about this.

  • #35530

    Points: 14
    Rank: Member

    Thanks Don, the stackoverflow article did get me over the hump.

    just in case someone else out there tries to find this info, basic code that i got to work was:

    ($datagridview1 was the name of the datagridview in this particular script)

    foreach ($DataGridViewRow in $datagridview1.Rows)
    $variable = $DataGridViewRow.Cells["COLUMNNAME"].Value

    obviously you can just call the value variable itself for utilization in the cmdlets

The topic ‘how do i utilize datagridview data as input for a script’ is closed to new replies.