I am new to building GUI's in Powershell.
I was able to build out my Datagrid but I am running into an issue where I can't delete rows if the editmode is set to EditOnEnter.
When it's set to EditOnEnter, the focus goes to the cell (appearing as if you are going to enter or change data) and prevents me from deleting the row.
However, If I set the editmode to the other options, as in EditOnKeystroke, I am able to delete the row. Is there a best practice approach to solving this? I prefer the editOnEnter mode; it's easier for the user.
Thank you for your help in advance.
Datagrid does not allow delete row when "EditOnEnter"
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.
Re: Datagrid does not allow delete row when "EditOnEnter"
In your delete code cancel the edit on the row before deleting it.
You can also select the row with the row header which will not start an edit. Once you are in edit mode delete is not available. Use the row selector (header) to select then delete the row.
You can also select the row with the row header which will not start an edit. Once you are in edit mode delete is not available. Use the row selector (header) to select then delete the row.
Re: Datagrid does not allow delete row when "EditOnEnter"
I just tested. Set grid to "EnterOnKeyStroke" to get it to allow deletions. "EditOnEnter" always forces the first cell to be entered whenever the record is selected.
To delete programmatically do the following:
This can be done in a button or in a context menu.
To delete programmatically do the following:
Code: Select all
$buttonDeleteRow_Click = {
$ix = $datagridview1.SelectedCells[0].RowIndex
$datagridview1.Rows.Remove($datagridview1.Rows[$ix])
}
Re: Datagrid does not allow delete row when "EditOnEnter"
Thank very much for your help. I will give this a try.