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

Cell Button position

Hi, I am using the dragbutton example and I would like to have the option to position the button to the left edge of the cell and resize the button to the size that I wanted. Is this doable for the gird? If so, can some one point me to the right direction? thanks, Patrick

4 Replies

AD Administrator Syncfusion Team June 15, 2004 06:46 PM UTC

If you are using the "DragButton" celltype, you can set the cell''s style.TextAlign = GridTextAlign.Right to put these buttons on the left (text to the right instead of to the default left). To set the size of the button, you need to change the ButtonBarSize = new Size(12*3, 12); in the DragButtonCellModel constructor. This sets 3 buttons to be 12x12.

AD Administrator Syncfusion Team June 16, 2004 11:47 AM UTC

Clay, I should make my question more precise. I want the text to align to the left but with the button positioned to the left of the text. The button needs to be all the way to the left edge of the cell (I am currently using only 1 button). Can I also change the size of the button whenever I change the height of the row? ie. ---------------------- | | | | | The Text | | | | ---------------------- | | This is the button. Thanks, Patrick

AD Administrator Syncfusion Team June 16, 2004 12:34 PM UTC

The only property the grid has to position text and buttons is style.TextAlign. If that does not do what you need, then in your renderer''s OnDraw method, you would have to position and draw the text yourself. If you look at the OnDraw method in GridStaticCellRenderer, it does something similar, putting the text immediately to the left of an icon. If you want your button height to grow with the row height, you can try just setting it to some max value. Most button classes in the grid will draw themselves at the minmum of the requested height or the cell height. By setting the requested height to a max value, you would just get the row height. Now I did not try this in the CellButtons sample, so I am not sure whether the drawing there is doing this type of thing. If not, in the Renderer.OnInitialize method, you could try setting the model.ButtonBarSize there taking into account Grid.Model.RowHeights(RowIndex).

AD Administrator Syncfusion Team June 16, 2004 03:23 PM UTC

Thank you. I got what I wanted.

Live Chat Icon For mobile
Up arrow icon