Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Go bottom
Message
From
05/11/2007 10:30:55
 
 
To
05/11/2007 09:23:40
General information
Forum:
ASP.NET
Category:
ADO.NET
Title:
Environment versions
Environment:
C# 2.0
OS:
Vista
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01266689
Message ID:
01266703
Views:
9
Sergio,

ADO.NET handles position in a DataTable with a different concept than VFP. The .Position property is a property of both the BindingContext and the CurrencyManager. In order to position the grid on the last record you just added, you have to set this .Position property.

DataGridViews may handle it differently than the old DataGrid (I haven't time this morning to look into it more thoroughly), but for now, the way I would have done it with the old DataGrid will work just fine:
CurrencyManager cm = (CurrencyManager)this.BindingContext[this.MyGrid.DataSource];

// set the position to the last row in the table
cm.Position = ((DataTable)this.MyGrid.DataSource).Rows.Count - 1;
Once you do that, the Grid will be positioned on that row.

You can also directly set the BindingContext's .Position property directly without having to create a CurrencyManager.
this.BindingContext[this.MyGrid.DataSource].Position = ((DataTable)this.MyGrid.DataSource).Rows.Count - 1;
~~Bonnie




>I have a datagridview bound to a dataset.
>I have inserted a new row in my dataset and I would like to go to the bottom of my dataset in order for my datagridview to see the latest inserted record.
>
>How do I go to the bottom of my dataset. In foxpro I would use :
>
>GO BOTTOM
>
>
>How do you do it in Dataset???
>
>Thanks
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Previous
Reply
Map
View

Click here to load this message in the networking platform