Accessing Data
Posted: Tue Jan 28, 2020 4:04 pm
I purchased the TGrid based upon all the demos, and tried them out and decided to purchase thinking that all the "standard" (compared to .net's data grid) data access routines would be similar. Unless I'm looking in the wrong place, there isn't any replication of the winforms .net data grid access, and it's very frustrating attempting to deal with user input and then refresh the data underneath.
For example, I'm querying data from a web service every minute. I'd like to make it appear seamless to the user so if they've selected a row, after the data is refreshed, if the data within the row is still there (not deleted, but updated) I'd like to re-select the row. Both as a row indicator and row highlight (full row select).
As a test, I've attempted to select row 1 no matter what the user clicks on using the code below. The grid will show other full row selects and keep the row "indicator" at 1. What I would expect to happen is that the row indicator stays at row 1 (the grid does this), AND the row selection stays at row 1 (grid does not do this). I'm OK with calling a line of code that selects the row, but unable to find that code.
All or part of the lines of code below will set the row indicator (far left "navigation" column) to row 1 (as expected), but the user can click on any other rows and the whole row is selected (would expect the row selected to go back to row 1).
private void Selected_Changed(object sender, EventArgs e)
{
GridMain.Selected.ChangeSelection(null, 1, Keys.Enter);
GridMain.Selected.FullRow = true;
sel = GridMain.Grid.Current.Selected;
GridMain.Selected.ChangeSelection(sel.Column, 1, Keys.Enter);
GridMain.Select();
}
The above code is just a test, but what I really want is when the data is refreshed, I'm going to look up the object that was previously selected (before the refresh), and then re-select the row (if the underlying data in the new object exists) after the refresh. I don't want the default row (probably row 0) highlighted, but the row indicator positioned at the found object row. They should both be pointing at or highlighting the same row.
Hope that makes sense.
thanks,
Curt
For example, I'm querying data from a web service every minute. I'd like to make it appear seamless to the user so if they've selected a row, after the data is refreshed, if the data within the row is still there (not deleted, but updated) I'd like to re-select the row. Both as a row indicator and row highlight (full row select).
As a test, I've attempted to select row 1 no matter what the user clicks on using the code below. The grid will show other full row selects and keep the row "indicator" at 1. What I would expect to happen is that the row indicator stays at row 1 (the grid does this), AND the row selection stays at row 1 (grid does not do this). I'm OK with calling a line of code that selects the row, but unable to find that code.
All or part of the lines of code below will set the row indicator (far left "navigation" column) to row 1 (as expected), but the user can click on any other rows and the whole row is selected (would expect the row selected to go back to row 1).
private void Selected_Changed(object sender, EventArgs e)
{
GridMain.Selected.ChangeSelection(null, 1, Keys.Enter);
GridMain.Selected.FullRow = true;
sel = GridMain.Grid.Current.Selected;
GridMain.Selected.ChangeSelection(sel.Column, 1, Keys.Enter);
GridMain.Select();
}
The above code is just a test, but what I really want is when the data is refreshed, I'm going to look up the object that was previously selected (before the refresh), and then re-select the row (if the underlying data in the new object exists) after the refresh. I don't want the default row (probably row 0) highlighted, but the row indicator positioned at the found object row. They should both be pointing at or highlighting the same row.
Hope that makes sense.
thanks,
Curt