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

GridTextBoxCellRenderer::OnDraw and ApplyText

In GridTextBoxCellRenderer::OnDraw, if I set style.ApplyText("Hello World!"); Will the displaystring in the grid from there on be "Hello World!", irrespective of what the cellvalue or cellvalue''s ToString is(which is what I want)?

4 Replies

AD Administrator Syncfusion Team December 2, 2005 12:54 AM UTC

If you just want to control the text that is displayed in cells, but not affect anything else (like the cell value, etc.), the try handling the grid.DrawCellDisplayText event. There set e.DisplayText to the text you want to see in the cell pointed to by e.Style.CellIdentity.RowIndex and e.Style.CellIdentity.ColIndex.


AD Administrator Syncfusion Team December 2, 2005 11:31 PM UTC

Having lot of problems with grid_DrawCellDisplayText. As you pointed out I am using e.Style.CellIdentity.RowIndex and e.Style.CellIdentity.ColIndex to set the DisplayText. However, whereas in the grid my Column = 4 is using a renderer say "MyRenderer", however in grid_DrawCellDisplayText, column 4 is not "MyRenderer" instead it is something else!!! in grid_DrawCellDisplayText, i have : if(this.GetType() == typeof(MyRenderer)) { Debug.WriteLine(e.Style.CellIdentity.ColIndex); } The colindex being printed out is 12 instead of 4 What gives?


AD Administrator Syncfusion Team December 3, 2005 01:03 AM UTC

OK i used Model_QueryCellFormattedText instead and it seems to be working fine. PLEASE LET ME KNOW IF YOU FORESEE ANY PROBLEMS WITH THIS EVENT.


AD Administrator Syncfusion Team December 3, 2005 01:38 AM UTC

>>if(this.GetType() == typeof(MyRenderer)) DrawCellDisplaytext is raised for every cell. So, since this code is in your renderer class, it will always be true as the ''this'' object is your renderer. It does not vary each time the DrawCellDisplaytext is raised. So, instead of testing this.GetType(), you might try: if(grid.GetCellRenderer(e.Style.CellIdentity.RowIndex, e.Style.CellIdentity.ColIndex) is MyRenderer)

Loader.
Live Chat Icon For mobile
Up arrow icon