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

WrapText in Gridcontrol static cell

Hi -
I have a comments column in my grid and am trying to set the WrapText to true for the cells in this column. Other columns should not wrap and should display ellipses.
Here's what i'm doing below, but it's having no effect. No text wrapping is occurring. Is there some other property preventing it?
Thanks,
Julie

protected void SetReadonlyCellProperties( GridStyleInfo cellStyle, string text, Type cellType, GridHorizontalAlignment hAlign, GridVerticalAlignment vAlign, bool wrapText )
{
cellStyle.Trimming = StringTrimming.EllipsisWord;
cellStyle.CellType = CELLTYPE_STATIC;
cellStyle.CellValue = text;
cellStyle.CellValueType = cellType;
cellStyle.HorizontalAlignment = hAlign;
cellStyle.VerticalAlignment = vAlign;
cellStyle.WrapText = wrapText;
cellStyle.AutoSize = wrapText;
cellStyle.ReadOnly = true;

}

22 Replies

HA haneefm Syncfusion Team March 29, 2007 08:22 PM UTC

Hi Julie,

Please try to provide us some more information on this issue. I tried to reproduce the issue, but couldn't. kindly provide us a small sample to reproduce the issue or modify any of our browser sample accordingly. This will help us to analyse the issue further.

Best regards,
Haneef


JL Julie Levy March 30, 2007 03:17 PM UTC

Hi -
Here is a sample demonstrating the problem. See Form1. I have turned on WrapText for one column but it is not wrapping.
Thanks,
Julie

Grid_MultiSelect2.zip


JL Julie Levy April 5, 2007 04:42 PM UTC

Hi -
any chance someone could look at this sometime soon?
Thanks,
Julie


HA haneefm Syncfusion Team April 9, 2007 11:30 AM UTC

Hi Julie,

One way you can do this by handling the DrawCellDisplayText event and draw the wraped display text using the DrawString method. the following is the code snippet

private void gridDataBoundGrid1_DrawCellDisplayText(object sender, GridDrawCellDisplayTextEventArgs e)
{
if( e.RowIndex > 0 && e.ColIndex > 0 )
{
if( e.ColIndex == 2) //Wrapped Col
{
e.Cancel = true; //cancel the default display text drawing
SolidBrush myBrush = new SolidBrush(e.TextColor);
e.Graphics.DrawString(e.DisplayText,e.Style.GdipFont,myBrush,e.TextRectangle,format);
}
}
}

Best regards,
Haneef


JL Julie Levy April 9, 2007 05:43 PM UTC

Hi Haneef -
thanks for your response.
So why doesn't the wraptext work? Is this a bug or am i misunderstanding the feature?
DrawCellDisplayText doesn't work either. Could you update the sample i attached and show me how to get the text to wrap. Note that i am not using a databound grid, but a regular grid control.
Thanks,
Julie


JL Julie Levy April 11, 2007 09:29 PM UTC

Hi -
any help on this getting wrap text to work?
Thanks,
Julie


JL Julie Levy April 13, 2007 06:31 PM UTC

nevermind, i figured out it


BR Brian Richards August 16, 2007 03:00 PM UTC

What did you do to resolve this Julie?


JL Julie Levy August 16, 2007 05:08 PM UTC

Hi -
if i remember correctly i had to resize the row heights to get the wrap to take effect. I am doing this when i load data and when the user resizes columns.

GridRangeInfo oRange = GridRangeInfo.Cols( from, to );
this.Model.RowHeights.ResizeToFit( oRange );

Hope this helps,
Julie


JJ Jisha Joy Syncfusion Team February 11, 2011 06:58 AM UTC

Hi Julie,

Thank you for your update.

Regards,
Jisha



BL blue replied to haneefm June 29, 2016 08:08 AM UTC

Hi Julie,

One way you can do this by handling the DrawCellDisplayText event and draw the wraped display text using the DrawString method. the following is the code snippet

private void gridDataBoundGrid1_DrawCellDisplayText(object sender, GridDrawCellDisplayTextEventArgs e)
{
if( e.RowIndex > 0 && e.ColIndex > 0 )
{
if( e.ColIndex == 2) //Wrapped Col
{
e.Cancel = true; //cancel the default display text drawing
SolidBrush myBrush = new SolidBrush(e.TextColor);
e.Graphics.DrawString(e.DisplayText,e.Style.GdipFont,myBrush,e.TextRectangle,format);
}
}
}

Best regards,
Haneef

I want rotate -90 . I set  "gridControlMain[rowNo, colNo].WrapRotatedText = true ; "   But  the text doesn't wrap .   Can you show me how to  do it ?


PM Piruthiviraj Malaimelraj Syncfusion Team June 30, 2016 05:10 AM UTC

Hi Blue, 

Thank you for using Syncfusion products. 

In order to rotate the text in a grid , you can use Orientation property of the cell style. Please make use of the below code, 

Code snippet 
this.gridControl1[rowIndex, colIndex].Font.Orientation = 90; 
 
Sample link 
 
UG Document: 
 
Note 
Please refer the below UG link for further references. 


Regards, 
Piruthiviraj 



BL blue July 5, 2016 03:12 AM UTC

Hi Julie,
The demo also can not wrap text after set orientation = -90; I want to make the text wrap.I set WrapRotatedText = true.But not work.


PM Piruthiviraj Malaimelraj Syncfusion Team July 5, 2016 12:55 PM UTC

Hi Blue, 
 
Thanks for your update. 
 
We had analyzed your scenario and analyzed with spread sheet also. We are little bit unclear with your scenario. In below images, we have set text orientation as (-90) in both GridControl and Excel . We need some more details of your query. Could you please provide us with the screen shots of your application which point out the your query? It would be more helpful for us to provide the exact solution at the earliest. 
 
GridControl: 
 
 
ExcelSheet: 
 
 
 
Regards, 
Piruthiviraj 



BL blue July 6, 2016 02:30 AM UTC

Yes. I want the first picture as above.  I download your sample code and add some code  behind the for loop. Like this
public Form1()
        {
            InitializeComponent();
            this.gridControl1.ColCount = 20;
            this.gridControl1.RowCount = 100;

            #region Grid's Data
            Random rnd = new Random();

            for (int c = 1; c <= this.gridControl1.ColCount; c++)
            {
                for (int r = 1; r <= this.gridControl1.RowCount; r++)
                {
                    int v = rnd.Next(100);
                    GridStyleInfo style = new GridStyleInfo();
                    style.Font.Size = 10f;
                    style.CellValue = v;
                    this.gridControl1[r, c].ModifyStyle(style, Syncfusion.Styles.StyleModifyType.Override);

                }
            }
            #endregion

            this.gridControl1[4, 4].Text = "123122343";
            this.gridControl1[4, 4].Font.Orientation = -90;
            this.gridControl1[4, 4].CellType = "Static";
            this.gridControl1[4, 4].WrapText = true;
            this.gridControl1[4, 4].WrapRotatedText = true;


        }

But the text not wrap. I don't know why. Can you give me your code?


PM Piruthiviraj Malaimelraj Syncfusion Team July 6, 2016 11:15 AM UTC

Hi Blue, 

Thanks for your update. 

We had analyzed your code from the provided code snippet. We had assigned the same text properties for the orientation cell. Could you please provide us with some additional information, whether the grid cell should appear in resized format (as in the image), while loading the grid for the first time. If so, please let us know your exact need to set the text in the grid cell. So that we could provide you the exact solution at the earliest. 

Regards, 
Piruthiviraj 



BL blue July 7, 2016 03:23 AM UTC

Sample link 

just change this sample code and change the code to

public Form1()
        {
            InitializeComponent();
            this.gridControl1.ColCount = 1;
            this.gridControl1.RowCount = 1;

            GridStyleInfo style = new GridStyleInfo();
            style.Font.Size = 10f;
            style.CellValue = "1234567890";
            this.gridControl1[1, 1].Font.Orientation = 270;
            this.gridControl1[1, 1].WrapText = true;
            this.gridControl1[1, 1].WrapRotatedText = true;
            this.gridControl1[1, 1].ModifyStyle(style, Syncfusion.Styles.StyleModifyType.Override);
        }

Then the text can not wrap. I just want to wrap this text.It's ok. I don't know how to wrap this text. Is it clear?


AG Anish George Syncfusion Team July 7, 2016 09:35 AM UTC

Hi Blue, 

Thank you for your update. 

Could you please let us know which Essential studio version you are using? Because wrap text related issues has been fixed in latest updates and some issues may be reproduce in our earlier version. If you are using any of our earlier version we request to migrate to our latest version Essential Studio Vol 2 2016 which is rolled out recently because we are unable to reproduce the issue in our latest version. As per your suggestion we tried the above sample with your code and found out that the cell has been wrapped as expected. Please refer the below screenshot.  

 

Please let us know if you need any further assistance. 

Regards, 
Anish. 



BL blue July 7, 2016 10:24 AM UTC

we use Version  11.4350.0.26 

Is this a  regression ?



AG Anish George Syncfusion Team July 8, 2016 04:14 AM UTC

Hi Blue, 
  
Thank you for your update. 
  
The reported issue is a known bug in the version 11.435.0.26. We request you migrate to our latest version to fix this issue. 
  
Please let us know if you need any further assistance. 
  
Regards, 
Anish 



BL blue July 8, 2016 08:13 AM UTC

Thanks. Have a good weekend


AG Anish George Syncfusion Team July 8, 2016 01:21 PM UTC

Hi Blue, 
  
Wish you the same. 
  
 Please let us know if you need any further assistance. 
  
Regards, 
Anish 


Loader.
Live Chat Icon For mobile
Up arrow icon