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
340
Error selecting text in read-only cell
posted

Hi,

I have a grid that does not allow the user to change any values.

What I want to do is higlight certian words in the value of a cell. I did this in another grid where the user is allowed to edit.

When I use the same method in the read-only grid, I get the following error, because the cell can't be set into edit mode.

"Selection related properties (SelText, SelStart and SelLength) are not supported while the cell is not in edit mode."

I would really like to use this functionality in my read-only grid.

 

This is my code:

                foreach (var row in grid.Rows.OrderBy(r => r.Index).Where(r => r.IsDataRow && r.Index >= startRow))
                {
                    UltraGridCell cell = row.Cells[columnn];
                    if (startPosition < cell.Text.Length)
                    {
                        if (cell.Text.ToLower().Substring(startPosition).Contains(searchText))
                        {
                            appearance = new TextAppearance
                                                {
                                                    Row = row,
                                                    Cell = cell,
                                                    Text = searchText,
                                                    TextPosition = cell.Text.ToLower().IndexOf(searchText, startPosition)
                                                };
                            grid.ActiveRowScrollRegion.ScrollRowIntoView(row);

                            cell.Activate();
                            grid.PerformAction(UltraGridAction.EnterEditMode);
                            cell.SelStart = appearance.TextPosition;
                            cell.SelLength = searchText.Length;
                            break;
                        }
                    }
                    startPosition = 0;
                }

 

Thanx