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.
Unfortunately, activation email could not send to your email. Please try again.

WrapText in Gridcontrol static cell

Thread ID:

Created:

Updated:

Platform:

Replies:

58867 Mar 29,2007 04:01 PM Jul 8,2016 09:21 AM Windows Forms 22
loading
Tags: GridControl
Julie Levy
Asked On March 29, 2007 04:01 PM

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;

}

haneefm [Syncfusion]
Replied On March 29, 2007 04:22 PM

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

Julie Levy
Replied On March 30, 2007 11:17 AM

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

Julie Levy
Replied On April 5, 2007 12:42 PM

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

haneefm [Syncfusion]
Replied On April 9, 2007 07:30 AM

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

Julie Levy
Replied On April 9, 2007 01:43 PM

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

Julie Levy
Replied On April 11, 2007 05:29 PM

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

Julie Levy
Replied On April 13, 2007 02:31 PM

nevermind, i figured out it

Brian Richards
Replied On August 16, 2007 11:00 AM

What did you do to resolve this Julie?

Julie Levy
Replied On August 16, 2007 01:08 PM

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

Jisha Joy [Syncfusion]
Replied On February 11, 2011 01:58 AM

Hi Julie,

Thank you for your update.

Regards,
Jisha


blue
Replied On June 29, 2016 04:08 AM

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 ?

Piruthiviraj Malaimelraj [Syncfusion]
Replied On June 30, 2016 01:10 AM

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 


blue
Replied On July 4, 2016 11:12 PM

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.

Piruthiviraj Malaimelraj [Syncfusion]
Replied On July 5, 2016 08:55 AM

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 


blue
Replied On July 5, 2016 10:30 PM

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?

Piruthiviraj Malaimelraj [Syncfusion]
Replied On July 6, 2016 07:15 AM

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 


blue
Replied On July 6, 2016 11:23 PM

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?

Anish George [Syncfusion]
Replied On July 7, 2016 05:35 AM

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. 


blue
Replied On July 7, 2016 06:24 AM

we use Version  11.4350.0.26 

Is this a  regression ?


Anish George [Syncfusion]
Replied On July 8, 2016 12:14 AM

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 


blue
Replied On July 8, 2016 04:13 AM

Thanks. Have a good weekend

Anish George [Syncfusion]
Replied On July 8, 2016 09:21 AM

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


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;