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

Grid Button

Hello, I have a custom button (MyButton form GridCellButton). I want to have access dynamicly properties from MyButton. (MyButton)gridControl(row, col) is not ok !! How have an access to MyButton in the grid? Stéphane.

3 Replies

AD Administrator Syncfusion Team October 25, 2005 12:14 PM UTC

I am not sure how you are setting up the grid to use your button, but if you are doing something like the EllipsisText button in the DrawButtons sample, then you can add a public member to the renderer class and set it when you create the button. public EllipsisCellButton myButton; public EllipsisCellRenderer(GridControlBase grid, GridTextBoxCellModel cellModel) : base(grid, cellModel) { myButton = new EllipsisCellButton(this) AddButton(myButton); } Then when you want to get your button, you can get it through the renderer. EllipsisCellRenderer cr = this.gridControl1.CellRenderers["EllipsisText"] as EllipsisCellRenderer; // access the button through cr.myButton


SA Stephane Augusto October 25, 2005 12:22 PM UTC

yes, i have used the EllipsisText button in the drawButtons sample. with "EllipsisCellRenderer cr = this.gridControl1.CellRenderers["EllipsisText"] as EllipsisCellRenderer", i have not access to the EllipsisCellButton from each cell. i have use gridControl.getCelleRenderer(row, col). But it''s the same problem. >I am not sure how you are setting up the grid to use your button, but if you are doing something like the EllipsisText button in the DrawButtons sample, then you can add a public member to the renderer class and set it when you create the button. > >public EllipsisCellButton myButton; > >public EllipsisCellRenderer(GridControlBase grid, GridTextBoxCellModel cellModel) > : base(grid, cellModel) >{ > myButton = new EllipsisCellButton(this) > AddButton(myButton); >} > > > >Then when you want to get your button, you can get it through the renderer. > >EllipsisCellRenderer cr = this.gridControl1.CellRenderers["EllipsisText"] as EllipsisCellRenderer; >// access the button through cr.myButton > > >


AD Administrator Syncfusion Team October 25, 2005 12:43 PM UTC

>>i have not access to the EllipsisCellButton from each cell There is not a separate button for every cell. A single button is shared by all cells that use your celltype. If you have 50000000000 cells using your celltype, it would be very inefficient to have 5000000000 different buttons. What you need to do is to store the cell specific information you want to use in the style for the cell (you can use the style.Tag for instance). Then in your renderer class, you would move the information from the style to your button as needed. Usually, this is done in the OnInitialize override in the renderer class for the active cell.

Loader.
Live Chat Icon For mobile
Up arrow icon