Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
New button on Business maintenance form
Message
 
À
29/08/2006 11:05:33
Xiaodong Yan
Better Database Solutions
Spring, Texas, États-Unis
Information générale
Forum:
ASP.NET
Catégorie:
The Mere Mortals .NET Framework
Divers
Thread ID:
01149381
Message ID:
01149604
Vues:
24
Sheldon,

>I set up a Business maintenance form.
>
>After sorting the list by clicking the column header. the NEW button will no longer bring up a blank record, instead, it brings up the last record in the list. The button works just fine if user doesn't sort the list before that.

I'm guessing that the new record DOES appear in the grid (you should see it if you scroll up) but it's no longer the last row because of the new sort order. To get around this, you need to bind your DataGrid to a DataView rather than the DataTable. For example:

BindingSource: Orders
BindingSourceMember: Orders.DefaultView

You should also set these binding properties on your New button. Now the problem is determining whether the new row is added as the first row or the last row (depending on how the grid is sorted), and then navigate to that row. To do this, override your form's NavigateNew() method. For example:
public override void NavigateNew()
{
	string SortOrder = ((DataView)this.grdCustomerOrders.DataSource).Sort;
	if (mmString.Empty(SortOrder))
	{
		this.NavigateData(mmNavigate.Last, false);
	}
	else
	{
		// Check the column being sorted and whether it's ascending (the default) or descending,
		// then decide if you should navigate to the first or last row based on where your new row
		// fits into the sort order
		// e.g.: this.NavigateData(mmNavigate.First, false);
	}
}
Best Regards,
Kevin McNeish
Eight-Time .NET MVP
VFP and iOS Author, Speaker & Trainer
Oak Leaf Enterprises, Inc.
Chief Architect, MM Framework
http://www.oakleafsd.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform