Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
2275
Filter Edit Control and Text Highlighting
posted

I have a situation where I want my users to be able to filter a grid and as they are typing I need to get the contents of the first row of results and highlight it.  The following code does just that, but the problem is that after the user types in the first letter, when the filter edit control gets the focus again, the letter is highlighted and if they continue typing they will overwrite the contents of the control.  I would like to change this to when the filter edit control gets the focus the cursor will be to the right of the last letter typed.

private void dgPatients_RecordFilterChanged( object sender, Infragistics.Windows.DataPresenter.Events.RecordFilterChangedEventArgs e )
{
	try
	{
		//
		// Get the current filter edit cell where the user is typing in the filter
		//
		Cell CurrentFilterEditCell = ( sender as XamDataGrid ).ActiveCell;

		//
		// Get all records that pass the filter.
		//
		IEnumerable<DataRecord> iedr = this.dgPatients.RecordManager.GetFilteredInDataRecords();
		if( iedr != null )
		{
			//
			// Cast list to DataRecord list and get the index of the first item.
			//
			List<DataRecord> ldr = iedr.ToList<DataRecord>();
			if( ldr.Count > 0 )
			{
				//
				// Get the index of the first record
				//
				int DisplayPosition = ldr[ 0 ].Index;

				//
				// Set the active record
				//
				this.SetActiveRecord( DisplayPosition );

				//
				// Get related information
				//
				Clinic clinic = new Clinic().Self( this.AppData.ActivePatient.ClinicID );
				Physician physician = new Physician().Self( this.AppData.ActivePatient.PhysicianID );

				//
				// Send out patient selected event so other tiles update
				//
				this.AppData.Events.OnPatientSelected( new PatientSelectedEventArgsthis.AppData.ActivePatient, clinic, physician, this.AppData.CurrentLoggedInPDUser, this.Name ) );
			}
		}

		//
		// Put the focus back on the edit control
		//
		this.dgPatients.ActiveCell = CurrentFilterEditCell;
		this.dgPatients.ActiveCell.DataPresenter.ExecuteCommand( DataPresenterCommands.StartEditMode ); // not highlight all, but appears at end?
	}
	catchException ex )
	{
		throw ex;
	}
}

Thank you.

Mike