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

CellDragButton

Hi all, I try to enhance the CellDragButton example. I want to insert different numbers of buttons in some cells. I tried to override the Draw method in the renderer but the buttons are always added. i want to clear the button collection, but i find no possibilty. What do i make wrong. Thanks for your help. Best regards Kai.

1 Reply

AD Administrator Syncfusion Team November 7, 2003 08:06 AM UTC

In the CellButton sample, the number of buttons is used both in the CellModel class where it sets the BarSize and the CellRenderer class in the constructor where its creates and adds the buttons. And any buttons that have been added using renderer.AddButtons will be drawn when the base class ondraw is called. So, if you do not want to see them, you have to remove them using renderer.RemoveButton before you call the base class draw. But the problem is dynamically changing these particular cellmodel/cellrenderer properties as the grid needs each cell (say to draw) will be involved. I think the simplest way to do this would be to create new CellModel/CellRenderer objects to handle differing numbers of buttons. You can change the sample code to pass the number of buttons in the model constructor and renderer constructor, and use that value to crate a varying number of buttons. Then use grid.CellModels.Add to add a different celltype for each number of button cells you need. gridControl1.CellModels.Add("Ellip1", new MyEllipsisCellModel(gridControl1.Model, 1)); gridControl1.CellModels.Add("Ellip2", new MyEllipsisCellModel(gridControl1.Model, 2)); gridControl1.CellModels.Add("Ellip4", new MyEllipsisCellModel(gridControl1.Model, 4)); Then you would set the CellType of any of your button cells to which of the "EllipX" is needed for the particular cell. And this could be done dynamcially if needed.

Loader.
Live Chat Icon For mobile
Up arrow icon