checkbox inside gridview

hi all,

in my GUI, I have a datagridview to display some information to the user. That datagrid has 2 columns;

a DataGridViewCheckBoxColumn and a DataGridViewTextBoxColumn

I need to read the value into the text cell whenever a user clicks in the checkbox to make his selection.

I am unable to retrieve the value of the text cell when the checkbox value changes to $True.

here’s my try of it;

    $datagridNotMembers_Click = {
        $rowIndex = $datagridNotMembers.SelectedCells.RowIndex
        $Name = $datagridNotMembers.Rows[$rowIndex].Cells[1].Value
        if ($datagridNotMembers.Rows[$rowIndex].Cells[0].Value -eq $True){
            Out-File -FilePath c:\Temp\nametest.txt -InputObject $Name
        }
    }

if I get the value of $datagridNotMembers.Rows[$rowIndex].Cells[0].Value, it is empty. how can I check if the checkbox is checked or not?

thank you!

If $checkbox is the object defined for CheckBox,you would use $Checkbox.Add_CheckStateChanged({‘whatever code here’}) event handler here when user clicks and $CheckBox.Checked to see whether it is in checked state or not.

looks like you didn’t read my post correctly.

it’s not a checkbox object, it’s a column into a datagridview defined as DataGridViewCheckBoxColumn

I am still unable to get the status of that cell, which contains a checkbox, when it is checked or not.

thanks!

assuming your checkbox is in the first column

[pre]
if ($DataGridViewRow.Cells[0].Value)
{
do something
}
[/pre]