r3nder
asked on
Datagridview index does not change when sorted on header click
I have a datagridview. When I click on the header and sort it asc or desc by a cell and then double click a selected row to load that record I find the index for that row is wrong - it loads the record that was originally at that index how can I fix that?
I tried this but that didnt work
I tried this but that didnt work
int jobnum1;
bool jobNum = int.TryParse(GV_DH.CurrentRow.Cells["run"].EditedFormattedValue.ToString(), out jobnum1);
if (jobNum == true)
{
int rowIndex = -1;
foreach (DataGridViewRow row in GV_DH.Rows)
{
if (Convert.ToInt32(row.Cells["run"].EditedFormattedValue.ToString()) == jobnum1)
{
rowIndex = row.Index;
break;
}
}
GV_DH_IndexChanged(rowIndex);
}
use the datagrid.refresh option to resort /redraw/recalculate indexes..
ASKER
sorry that didn't help, I wish it had :D
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
moved in another direction
ASKER
Open in new window