AutoComplete Control

Hi,

I am using the auto complete control to present the user a list of patient names. The control works well. The issue is that when a patient is selected I am trying to figure out how to uniquely identify that patient (i.e. with a unique identifier) is there a way this can be done with the auto complete control?

Thanks,

Scott

1 Reply

AJ Ajish Syncfusion Team August 2, 2007 11:56 PM UTC

Hi Scott,

This can be done by setting a datasource for the autocomplete datasource having multicolumns one column as the unique key of the Patient and another as the Patient Name. Using this relation we can get the unique identity of the patient. Here is the code for setting datasource with multiple column

for (int i = 0; i < 10; ++i)
{
DataRow dr = dt.NewRow();

dr[0] = "Patient"+ i.ToString();
dr[1] = RandomString(ran.Next(9));

dt.Rows.Add(dr);

}

this.autoComplete1.DataSource = dt;
this.autoComplete1.RefreshColumns();

this.autoComplete1.Columns[1].MatchingColumn = true;
this.autoComplete1.Columns[0].Visible = false;

and the Autocomplete item selection event can be used to identify the unique id of the patient. Here is the code for it,

private void autoComplete1_AutoCompleteItemSelected(object sender, Syncfusion.Windows.Forms.Tools.AutoCompleteItemEventArgs args)
{
if (this.autoComplete1.SelectedIndex >=0)
{
Console.WriteLine(dt.Rows[this.autoComplete1.SelectedIndex][0].ToString());
}
}

Here is the sample for your reference,

Sample: http://websamples.syncfusion.com/samples/Tools.Windows/F66784/main.htm

Kindly take a look and let me know if this helps.

Regards,
Ajish.

Loader.
Up arrow icon