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 PatientSelectedEventArgs( this.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? } catch( Exception ex ) { throw ex; } }
Thank you.
Mike
Hello Mike,
I am very glad that the approach I have suggested in the other forum thread was helpfil for you. Please let me know if you need any further assistance on the matter.
Sincerely,
Krasimir
Developer Support Engineer
Infragistics
www.infragistics.com/support
Thanks Krasimir. Yes your approach was very helpful. I don't know why I did not see it until now. I missed getting the reply email.
Thanks again for all of your help.
Thank you for your post. I have been looking into it and the issue that you have described seems the same as the one that you have posted in the following forum thread: http://community.infragistics.com/forums/t/70421.aspx . I have already replied to that forum thread.
Please let me know if this issue is the same as the one in the thread I have mentioned or I have misunderstood you in any way.
I am still hoping I can get some help with this issue.
Any thoughts?