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

Custom Cell Drawing

Hi,

I have written a user control that embeds within it a sync fusion grid. I am trying to use the grid in virtual mode, and the model for the data is in a custom object model - I am not using te model on the gridcontrol itself.

Te problem I have is I need to get involved in how a cell is drawn. Depending on certain conditions, I might want to draw two pieces of text in a single cell, one with a different background to the other piece of text. I was hoping I could override DrawCell, but I'm not sure how to go about that now. I'm also wondering if it would be simpler to create a CustomCell instead?

Any advice on the *simplest* way of achieving what I want would be most appreciated.

Thanks,

Nick.

2 Replies

NI Nick October 14, 2007 01:18 PM UTC

Hi,

I am drawing text very simply by first painting the background and then painting the text on OnDrawCell:

e.Graphics.DrawString(value, font, new SolidBrush(value.Style.TextColor), e.Bounds);

The problem I now have is that the borders on the cells are showing. If I let the grid draw itself, handling only QueryCellInfo, I can switch off the border to each cell using the following:

style.Borders.All = GridBorder.Empty;
style.CellAppearance = GridCellAppearance.Flat;

Where style is a reference to the TableStyle on my grid.

Any advice on how to deal with the borders?

Thanks,

Nick.


HA haneefm Syncfusion Team October 17, 2007 12:12 AM UTC

Hi Nick,

Please try setting the Borders property in a PrepareViewStyleInfo event.Below are the codes:

e.Style.Borders.All = GridBorder.Empty;

Best regards,
Haneef

Loader.
Live Chat Icon For mobile
Up arrow icon