Get value of cell based on another cell from datagridview
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.
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.
Get value of cell based on another cell from datagridview
I know how to get selectedvalue from area 1 with : $datagridviewResultsLogs.SelectedCells[0].Value
but how do i get the value in area 2 when selecting cell from area 1 - the same row.
Re: Get value of cell based on another cell from datagridview
Use the column name and not the index. The index is transient and the name always specifies the correct column.
$datagridviewResultsLogs.SelectedCells['Device'].Value
$datagridviewResultsLogs.SelectedCells['Device'].Value
Re: Get value of cell based on another cell from datagridview
Code: Select all
$SelectedCell = $datagridviewResultsLogs.SelectedCells['Device'].Value
$SelectedLogfilename = $datagridviewResultsLogs.Rows[$($datagridviewResultsLogs.CurrentCell.RowIndex)].Cells[1].Value
$SelectedDevice = $datagridviewResultsLogs.Rows[$($datagridviewResultsLogs.CurrentCell.RowIndex)].Cells[0].Value
$script:selectedlogfile = "\\$SelectedDevice\$logdir\$SelectedLogfilename"