Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Autocomplete function for datagridview
Message
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Environment versions
Environment:
C# 3.0
OS:
Windows Server 2003
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Desktop
Miscellaneous
Thread ID:
01429055
Message ID:
01433027
Views:
57
Linda,

>I got this to work as described at that site. It suggests creating an AutoCompleteStringCollection variable at the form level, which I will call acsTest. Then, the code below is loaded in the EditingControlShowing event of the grid.

Glad to hear it worked for you!

>It seems like you also ought to be able to set the AutoComplete values after the form's InitializeComponent() so it just executes once, rather than each time you enter the cell in the grid but I'm not having good luck getting a reference to the control in the grid. I thought the Controls collection might let me do that but it only has 3 controls at startup. Is there some other place I can get that reference?

Here is some code from MM .NET's mmGridView.BindBack() method that shows how to access cells in a GridRowView that may help you out:
GridViewRow item = this.Rows[this.EditIndex];

int CellNumber = 0;

foreach (TableCell cell in item.Cells)
{
	// Need to check HasControls because if a column is set to ReadOnly,
	// HasControls() returns false. Trying to process the controls collection
	// when HasControls() is false, throws an exception.
	if (cell.HasControls())
	{
		DataControlField column = this.Columns[CellNumber];

		BoundField BoundCol = column as BoundField;
		if (BoundCol != null)
		{
			TextBox TxtBox = cell.Controls[0] as TextBox;
			if (TxtBox != null)
			{
				mmReflection.SetPropertyValue(entityList[this.EditIndex], BoundCol.DataField, TxtBox.Text);
			}
			else
			{
				CheckBox ChkBox = cell.Controls[0] as CheckBox;
				if (ChkBox != null)
				{
					mmReflection.SetPropertyValue(entityList[this.EditIndex], BoundCol.DataField, ChkBox.Checked);
				}
			}
		}
	}
	CellNumber++;
}
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