Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Displaying broken rules from a DataGrid
Message
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Miscellaneous
Thread ID:
00950902
Message ID:
00951197
Views:
12
Ric,

>Is there any point in using the .NET Error Provider to display broken rules within a (Winforms) datagrid?
>
>I've tried it, and the little error icon appears in the correct column, but always in the first row, even if the error is related to some other row.
>
>This is a basic header-detail form, with an Order shown at the top of the form, and a DataGrid of OrderLines shown at the bottom of the form.

If you specify the row number in which the error occurs within your rule object, then the error icon appears next to the correct row. For example, in the following code, as each OrderDetail row is processed, the current row number is stored in the business rule object's CurrentRow property. MM .NET picks up this value and passes it along to the error provider which displays the error icon in the appropriate row:
public override bool CheckRulesHook(DataSet ds, string tableName)
{
	bool result = true;
	int RowCount = ds.Tables[tableName].Rows.Count;
	for (int row=0; row<RowCount; row++)
	{
		this.DataRow = ds.Tables[tableName].Rows[row];
		this.CurrentRow = row;

		if (this.DataRow["Quantity"] is Int16)
		{
			this.ValidateQuantity((System.Int16)this.DataRow["Quantity"]);
		}
		else
		{
			this.ValidateQuantity((int)this.DataRow["Quantity"]);
		}
		this.ValidateProductID((int)this.DataRow["ProductID"]);
	}
	return result;
}
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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform