Display full text in GridTextBoxCellModel

Hi, I am using a custom cell like EllipsisCell from from the sample Essential Studio\4.2.0.37\windows\Grid.Windows\Samples\In Depth\CellButtons\CS in a Syncfusion.Windows.Forms.Grid.GridControl runnig in virtual mode. I am using GridShowButtons.ShowCurrentCell. This works fine except that the text of a cell always shows space for the buttons (in my application two or three buttons) even then they are not shown. I deleted the line innerBounds.Width -= 40; in GridTextBoxCellRenderer.OnLayout and the text is shown in the whole cell but my buttons are overwritten by the text. How can I set the inner bounds to another value when buttons are shown and not shown? Regards, Christian

2 Replies

AD Administrator Syncfusion Team June 8, 2006 05:37 AM UTC

Hi Christian, You need to check the current cell for detecting the cell button visbility of the cell with GridShowButtons.ShowCurrentCell option in a grid. Here is a code snippet. /// protected override Rectangle OnLayout(int rowIndex, int colIndex, GridStyleInfo style, Rectangle innerBounds, Rectangle[] buttonsBounds) { TraceUtil.TraceCurrentMethodInfo(rowIndex, colIndex, style, innerBounds, buttonsBounds); // Here you specify where the button should be drawn within the cell. Rectangle rightArea = Rectangle.FromLTRB(innerBounds.Right-20, innerBounds.Top, innerBounds.Right, innerBounds.Bottom); buttonsBounds[0] = GridUtil.CenterInRect(rightArea, new Size(20, 20)); // Here you return the area where the text should be drawn/edited. //To Check the button shown or not shown. if( style.ShowButtons == GridShowButtons.ShowCurrentCell || style.ShowButtons == GridShowButtons.ShowCurrentCellEditing ) { // For ShowCurrentCell option button show after click the cell. if( rowIndex == this.CurrentCell.RowIndex && colIndex == this.CurrentCell.ColIndex) { innerBounds.Width -= 20; //For button shown } } else if ( style.ShowButtons == GridShowButtons.Hide ) innerBounds.Width -= 0; else innerBounds.Width -= 20; return innerBounds; } Let me know if this helps. Regards, Haneef


CL Christian Lützenkirchen June 8, 2006 08:21 AM UTC

Hi Haneef, your sample works fine. Thank you very much for your help! Regards, Christian

Loader.
Up arrow icon