Hello,
I am working on a powershell GUI project and have a datagridview with data i pulled from SQL that part works.
What i want to do it get a rows of a column to show in a combobox for selection.
Later i want to click a button to query the other columns of the row the username is on to populate text boxes.
Here is my code so far minus the SQL part that works.
Add-Type -AssemblyName System.Windows.Forms
[System.Windows.Forms.Application]::EnableVisualStyles()
$Form = New-Object system.Windows.Forms.Form
$Form.ClientSize = '800,500'
$Form.text = "Form"
$Form.TopMost = $false
$Form.FormBorderStyle = 'Fixed3D'
$Form.MaximizeBox = $false
#$gps | foreach {$dataGridView.Rows.Add($result)}
#$list = New-Object System.collections.ArrayList
#$list.AddRange($gps)
$dataGridView = New-Object System.Windows.Forms.DataGridView -Property @{
Size=New-Object System.Drawing.Size(800,400)
ColumnHeadersVisible = $true
DataSource = $table
}
$dataGridView.location = New-Object System.Drawing.Point(4,2)
$dataGridView.SelectionMode = 'FullRowSelect'
$dataGridView.MultiSelect = $true
$ComboBox1 = New-Object system.Windows.Forms.ComboBox
$comboBox1.DropDownStyle = [System.Windows.Forms.ComboBoxStyle]::DropDownList;
$ComboBox1.text = ""
$comboBox1.Sorted = $true
$ComboBox1.width = 190
$ComboBox1.height = 20
$ComboBox1.location = New-Object System.Drawing.Point(171,427)
$ComboBox1.Font = 'Microsoft Sans Serif,10'
$connection.Close()
$Form.controls.AddRange(@($DataGridView,$ComboBox1))
$form.ShowDialog()
Example of the SQL datagridview output:
RecordNumber FirstName------------ ---------
4077 Brandie
4126 Ashley
4136 Christine
4139 Shaleka
4140 Deulis
4142 Tiana
4145 Elysa
4146 Terri
4148 Paul
4152 Kourtney
4156 Edward
4158 Karla
4159 Atiya
4161 Lakeya
4164 Amiri