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
15
Incremental search in UltraGrid
posted

As discussed in this question: https://www.infragistics.com/community/forums/f/ultimate-ui-for-windows-forms/78391/incremental-keyboard-search-on-ultrawingrid-ultragrid

Is there a built in feature that supports incremental search? So if on the grid, I begin typing "me" it should jump to a row with a column that starts with that. Dev Express has this feature: https://documentation.devexpress.com/WindowsForms/114648/Controls-and-Libraries/Data-Grid/Getting-Started-With-Data-Grid-and-Views/Walkthroughs/Filter-and-Search/Tutorial-Incremental-Search

Please let met know how we can achieve that without the filter row.

  • 26425
    Offline posted

    Hello Eti, 

    You can utilize our implementation from our documentation by iterating the rows, enter edit mode, perform a SelStart, SelLength, and return the character or phrase. Note, the row object has a IsDataRow property, and IsFilterRow. You can place an "If" check carry out these parameters. 

    if ( null != row )
    {
    	Type rowType = row.GetType( );
    
    	bool isDataRow = row.IsDataRow;
    	bool isGroupByRow = row.IsGroupByRow;
    	bool isFilterRow = row.IsFilterRow;
    	bool isSummaryRow = row.IsSummaryRow;
    	bool isTemplateAddRow = row.IsTemplateAddRow;
    }

    eg. 

    public static void FindPhrase(UltraGrid grid, String s)
            {
                           foreach (UltraGridRow row in grid.Rows)
                {
                    foreach (UltraGridCell cell in row.Cells)
                    {
                        if (cell.Text.Contains(s))
                        {
                            //The cell must be activated first
                            cell.Activate();
                            //Cell must be in edit mode to perform selection
                            grid.PerformAction(UltraGridAction.EnterEditMode);
                            //Start the selection
                            cell.SelStart = cell.Text.IndexOf(s);
                            //For this length
                            cell.SelLength = s.Length;
                            //For eye candy, make this the first visible row
                            grid.DisplayLayout.RowScrollRegions[0].FirstRow = row;
                            return;
                        }
                    }
                }
            }

  • 467330
    Offline posted

    Here's a sample I wrote a while back with a class that automatically does a search on the sorted column of the grid: 

    ultrawingrid_keyboard_search_cs.zip