Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Finding a record in a grid
Message
 
To
16/05/2005 13:18:03
Dave Porter
Medical Systematics, Inc.
Merced, California, United States
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Miscellaneous
Thread ID:
01014618
Message ID:
01014757
Views:
29
Dave,

>I have a simple maintenance form ( http://www.zmsi.com/Grab52.png ).
>The table has 15,000 plus records in it and I'm trying to figure out a way to quickly locate a record. I put a mmpicker on the form and I have the picker working. Working in that it is returning the primary key value for the record found. What I want to do is move to the grid and find the record in the grid returned by the picker. OR some other idea or easier way to locate a record the grid...

Here is the code for mmPickListForm that does incremental searching in grids using the Windows Forms Currency Manager. You can steal from this code to find and select a specific row in a DataGrid:
int RowID = -1;

if (!mmString.Empty(this.txtSearch.Text))
{
	CurrencyManager cm = this.grdPickList.GetCurrencyManager();
	DataView dv = (DataView)cm.List;
	DataTable dt = dv.Table;

	DataRow[] rows = dt.Select(string.Format(this.SortColumnField + " like '{0}%'", this.txtSearch.Text), dv.Sort);

	if (rows.Length > 0)
	{
		RowID = dv.Find(rows[0][this.SortColumnField]);
	}
}
			
this.grdPickList.ClearSelectedRows();
			
if (RowID >= 0)
{
	this.grdPickList.SelectRow(RowID);
	this.grdPickList.CurrentRowIndex = RowID;
}
else
{
	this.grdPickList.CurrentRowIndex = 0;
	this.grdPickList.ClearSelectedRows();
}
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