GridDataBoundRowExpandCellButton

Hello, I''m trying to replace view of Expand cell button of GridDataBoundGrid with my own images for collapsed/expanded states. I created my own ExpandCellModel (descendant of GridDataBoundRowExpandCellModel) which uses ExpandCellRenderer (descendant of GridDataBoundRowExpandCellRenderer) that again uses ExpandButton( descendant of GridDataBoundRowExpandCellButton). In ExpandButton class method Draw is overrided: public override void Draw(Graphics g, int rowIndex, int colIndex, bool bActive, GridStyleInfo style) { Bitmap image = expanded ? _expanded :_collapsed; g.DrawImage(image, Bounds.Left, Bounds.Top); } added in constructor of the grid this.Model.CellModels.Add("ExpandCellModel", new CustomGridCell.ExpandCellModel(this.Model)); and in handler of GridDataBoundGrid.PrepareViewStyleInfo for cell with appropriate number of column e.Style.CellType = "ExpandCellModel"; but method ExpandButton.Draw is never executed, and expand button stays same, no my images are presented. Can you suggest something? Thank you

2 Replies

AD Administrator Syncfusion Team August 24, 2005 04:36 PM UTC

In the constructor of your renderer class, I think you will have to remove the button (there is a protected renderer.RemoveButton method) that was added in the base class constructor and then add an instance of your own button. I suspect it is this baseclass button still being used is the reason you do not see your code being hit.


AD Administrator Syncfusion Team August 25, 2005 12:48 PM UTC

Yes, that is working, thank you very much. I''ve also discovered that button remembers it state only when current cell is avctive: I used functions IsPushed and IsMouseDown to determine state of the button in the Draw method. As I see own Expand buttons of GridDataBoundGrid remembers their state - they store it in GridStyleInfo.CellValue. So now I do the same - and my custom Expand button works good. Thank you again.

Loader.
Up arrow icon