• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 267
  • Last Modified:

DataGrid Position

I have a datagrid that lists a bunch of appointments.  The user scrolls down the datagrid to view appointments that are further down in the list.  The problem comes in when the screen refreshes.  It is set to refresh the data every 30 seconds.  Every time the DataTable that is bound to the datagrid gets refreshed(by a DataAdapter.Fill), the DataGrids view returns back to the first row and you have to scroll down to the specific row again.  How can I stop the reposition of the datagrid???????

Thanks,
Kendal
0
gvector1
Asked:
gvector1
  • 4
  • 2
1 Solution
 
YurichCommented:
you can probably try to get the selected row before refreshing and select it again as a current row after refreshing...

something like:

// just before refreshing
int row = dg.CurrentRowIndex;

// do all refreshing
...

// and then
dg.CurrentRowInex = row;

regards
0
 
gvector1Author Commented:
The problem is that there is no currently selected row.  The datagrid is just scrolled, nothing is selected.
0
 
gvector1Author Commented:
Any Ideas????
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
YurichCommented:
I would probably suggest trying to use DataView somehow since you're changing exactly that one when you're scrolling your datagrid but can't offer anything solid, sorry.
0
 
gvector1Author Commented:
I cannot figure out how to use a dataview to accomplish that.  Any pointers????
0
 
gvector1Author Commented:
I have run across an approach to accomplish this:

FieldInfo fi = typeof(DataGrid).GetField("firstVisibleRow",BindingFlags.NonPublic | BindingFlags.Instance);
                  int rownum = Convert.ToInt32(fi.GetValue(dataGrid1));

MySqlDataAdapter da = new MySqlDataAdapter(cmd);
dttemp.Clear();
da.Fill(dttemp);      

dataGrid1.ScrollToRow(rownum);
0
 
CetusMODCommented:
PAQ'd, 500 points refunded.
CetusMOD
Community Support Moderator
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now