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

Grid DrawEvent, have drawing and cellValue show in the Grid at the same time

Hi,

I'm trying to draw a maker in the cell, by using the GridDrawCellEvent.  Also, I use e.cancel = true to keep the marker in the cell all time.  At the same time, I put a text string in the same cell by using QueryCellInfo event. But the text doesn't show.

So, If I have

private void gridControl_QueryCellInfo(object sender, GridQueryCellInfoEventArgs e)
        {
              e.Style.CellValue="a text message";
        }

private void gridControl_DrawCell(object sender, GridDrawCellEventArgs e)
        {
              e.Graphics.FillPolygon(blueBrush, curvePoints, newFillMode);
        }

then, the text string is showing, but the drawing is not stable.  When the mouse hovers over the cell, the drawing is gone (or mouseClick);

if I have

private void gridControl_QueryCellInfo(object sender, GridQueryCellInfoEventArgs e)
        {
              e.Style.CellValue="a text message";
        }

private void gridControl_DrawCell(object sender, GridDrawCellEventArgs e)
        {
              e.Graphics.FillPolygon(blueBrush, curvePoints, newFillMode);
              e.Cancel = true;
        }

then, the drawing is stable, but the CellValue does not show.

Is there a way to fix the drawing and also be able to show the CellValue ?

Thank you for your help!!
Jiali

3 Replies

KB Kalaiarasan B Syncfusion Team August 16, 2012 10:14 AM UTC

Hi Jiali

Please try both the actions in a the DrawCell event. Use the Graphics.DrawString to write the cell value in the cell along with the cellvalue.

 void gridControl1_DrawCell(object sender, GridDrawCellEventArgs e)
        {
            e.Graphics.DrawString(arguments)
        }

Please let me know if you have any concerns

Regards,
Kalai


AD Administrator Syncfusion Team August 16, 2012 01:57 PM UTC

Hi Kalaiarasan,

DrawString can draw out the text, but its a good solution for my case.  Is there a way to fix the drawing in the cell, and also be able to set cell value through e.style.cellValue?

Thank you for your help
Jiali


KB Kalaiarasan B Syncfusion Team August 17, 2012 11:06 AM UTC

Hi Jiali,

While handling the drawing and Cellvalue separately in cell, the querycellinfo event will be triggered lastly after DrawCell, so it makes only either of it exists. So you can try both the changes in QueryCellinfo event, by drawing both image and text in a cell.

 Check with this sample : http://www.syncfusion.com/downloads/Support/DirectTrac/89251/ImageCellandText1846318368.zip

Please let me know if this helps

Regards,

Kalai


Loader.
Live Chat Icon For mobile
Up arrow icon