Grid: keep focus when refresh(?)
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: Grid: keep focus when refresh(?)
Never mind, it doesn't work at all anymore now.
After I did a simple change from yes to no, then again to yes, selection doesn't work. I give up.
After I did a simple change from yes to no, then again to yes, selection doesn't work. I give up.
Re: Grid: keep focus when refresh(?)
You can't use yes/no for Booleans. You must use the special variables $true and $false. Aby text will always evaluate to true even if it spelled "false" and PS doesn't recognize YES/NO or Ok or any other English terms.
Re: Grid: keep focus when refresh(?)
I had a few minutes today so I cobbled together a simple example of how this works so you can see if it matches what you are doing. Your actual code would have made this much easier.
The method used has variations depending on how your form's behavior is set.
The method used has variations depending on how your form's behavior is set.
- Attachments
-
- Test-DGVRowSelect.psf
- (16.03 KiB) Downloaded 98 times
Re: Grid: keep focus when refresh(?)
In order to keep the focus on the line, I advise you to read the information on solving this problem in this foru . There are many helpful hints there.
Re: Grid: keep focus when refresh(?)
Thanks! You didn't ask for the code btw.jvierra wrote: ↑Fri Oct 30, 2020 8:35 pm I had a few minutes today so I cobbled together a simple example of how this works so you can see if it matches what you are doing. Your actual code would have made this much easier.
The method used has variations depending on how your form's behavior is set.
Your example selects a cell, I would need to select a full row.
This is the code:
In Action "SelectionChanged" on DataGridview
$Global:LastSelectedRowDataGridView01 = $datagridview01.SelectedRows[0].Index
On Load of DatagridView01
$DataGridView01.[$LastSelectedRowDataGridView01].Selected = $true
Re: Grid: keep focus when refresh(?)
Ok, I see what is happening.
The selected index row is ok, but when refresh happens selectionchanged is also triggered and the value of selected index is 0 again
The selected index row is ok, but when refresh happens selectionchanged is also triggered and the value of selected index is 0 again