We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

CurrentCell.Renderer.ControlText

Hello again... We have a new problem: we need to get the *current* text displayed in a grid cell. As far as we can tell, grid[i, j].FormattedText will call straight through to our data model without reference to the text currently in the cell (which is OK, so far as it goes). When a user clicks on a cell, types some text, then clicks off the grid, our code sets a new value in our CellQueryFormattedText handler (since the cell is from our perspective no longer active, even if it is still the grid''s "current" cell). A human user can see the cell display the new value just fine; however, our automated testing framework (which gets the "active" text from the cell by getting CurrentCell.Renderer.ControlText) still sees the cell value as if the cell were "active". What might the cause of the mismatch be?

3 Replies

AD Administrator Syncfusion Team March 9, 2006 03:44 PM UTC

Hi William, By design the GridCurrentCell.Renderer.ControlText will get the active text from the cell. To get the display text, you can go for the DrawCellDisplayText event to get the displaytext ( e.DisplayText ) of the current cell or by using e.FormattedPreview property in QueryCellFormattedText event will bring you the solution. Best Regards, Madhan.


WR William Reade March 13, 2006 11:25 AM UTC

Hi Madhan Thanks for your response, but I think I must be missing something -- as far as I can tell, the DrawCellDisplayText event does not fire while the cell is being edited, and the QueryCellFormattedText event has no FormattedPreview property. I need a way of getting the actual text in a grid cell, while it is being edited (ie I expect to get a different result after every keystroke). Is this possible? Cheers William


AN Anonymous March 14, 2006 10:46 AM UTC

Hi everyone We seem to have a working solution, even if it''s a bit ugly; if anyone ever needs to do the same, hopefully this will come in handly. Register for DrawCell, DrawCellDisplayText, and PrepareViewStyleInfo events, and maintain your own list of cell contents to query later. Whenever you get a DrawCell event, clear out the text for the corresponding cell; whenever you get a DrawCellDisplayText event, set the corresponding cell''s text to DisplayText; and whenever you get a PrepareViewStyleInfo event for the currently-being-edited cell, *and* the current cell''s Renderer has a Control, *and* that Control has a Text, set the corresponding cell''s text to that of the control. This is not foolproof -- if you happen to query your list in between a DrawCell and DrawCellDisplayText, for example, you''ll get a misleading answer -- but these issues can be worked around by judiciously sleeping here and there. It isn''t great, but it works; however, if anyone can suggest any improvements, please do so :-). Cheers William

Loader.
Live Chat Icon For mobile
Up arrow icon