Column Header text WordWrap - Farpoint.win.TextRenderer.dll Problem

Posted by: rprabhu on 8 September 2017, 2:15 pm EST

  • Posted 8 September 2017, 2:15 pm EST

    Hi All,

      To prevent word wrapping in Column Header text, we make the column header as text celltype and set the wordwrap property to false. Following is the code snippet,

                 sshLogin.ActiveSheet.SetColumnLabel(0, 1, "Comments");

                sshLogin.ActiveSheet.Columns[1].HorizontalAlignment = FarPoint.Win.Spread.CellHorizontalAlignment.Left;

                sshLogin.ActiveSheet.SetColumnWidth(0, 16);

                FarPoint.Win.Spread.CellType.GeneralCellType c = new FarPoint.Win.Spread.CellType.GeneralCellType();

                c.WordWrap = false;

                c.StringTrim = StringTrimming.Character;

                sshLogin.ActiveSheet.ColumnHeader.Columns[1].CellType = c;


      So, according to the above code i can see only letter "C" in my second column header, which is the desired output. But this code does not works fine if we have Farpoint.Win.TextRenderer.dll in our output path. Please provide some workaround to get the same desired output with Farpoint.Win.TextRenderer.dll still in the output path. I also have attached a sample.

     

    Thanks,

    Prabhu R 


    2010/03/SampleFarpointCellClick-2.zip
  • Replied 8 September 2017, 2:15 pm EST

    Thanks Reeva Dhingra....I'll make a check.


     Thanks,


    Prabhu R

  • Replied 8 September 2017, 2:15 pm EST

    Thanks Reeva...
  • Replied 8 September 2017, 2:15 pm EST

    Hello,

    I am unable to replicate the issue at my end. Have you tried it with setting GeneralCellType's wordWrap property to true? Please have a look at the attached screen-shot for the output I am getting.

                fpSpread1.ActiveSheet.SetColumnLabel(0, 1, "Comments");

                fpSpread1.ActiveSheet.Columns[1].HorizontalAlignment = FarPoint.Win.Spread.CellHorizontalAlignment.Left;

                fpSpread1.ActiveSheet.SetColumnWidth(1, 16);

                FarPoint.Win.Spread.CellType.GeneralCellType c = new FarPoint.Win.Spread.CellType.GeneralCellType();

                c.WordWrap = true;

                c.StringTrim = StringTrimming.Character;

                fpSpread1.ActiveSheet.ColumnHeader.Columns[1].CellType = c;

    Let us know your observations on the same.



  • Replied 8 September 2017, 2:15 pm EST

    Hi All,

      This issue re-occurs with Farpoint 5.0.3511. Can you have look at it and confirm?

    Thanks,

    Prabhu R 

     

     

  • Replied 8 September 2017, 2:15 pm EST

    Hello Prabhu,


    This has been replied here.


    Thanks.

  • Replied 8 September 2017, 2:15 pm EST

    Hello Prabhu,


    In order to get only "C" as Column Header's text in Column 1, you can try upgrading your Spread to the latest maintenance release of Spread which is version 4.0.3515.2008 and also set the WordWrap property of the GeneralCellType to true to get the desired output.


    You can get the downloads from ftp://ftp.fpoint.com/SpreadWinForms4/.


    Hope this will help you. Thanks.

  • Replied 8 September 2017, 2:15 pm EST

    Hello,

    I have reported bug for the original issue only i.e. TextRenderer.dll issue and the bug number for the same is #99918711 and it will be fixed in the future maintenance release of Spread 5. and as of now I am not finding any other workaround for the same except for the one suggested above.

    Thanks.

  • Replied 8 September 2017, 2:15 pm EST

    Hi Reeva, is the bug you logged around the alignment issue? Or is it about the original issue in TextRenderer?

    It would be great if we can get the original issue addressed.

     

    Thanks! 

  • Replied 8 September 2017, 2:15 pm EST

    Thanks Reeva, 

    Another issue with the previous fix i.e. general celltype suggested by you is if we increase the column height, i could see the wrapped text, which is not similar to VB.

    Coming to the latest fix suggested by you, the header text will be always be showing "C" even when i increase the column width. Again its not similar to VB.

    Thanks,

    Prabhu R 

  • Replied 8 September 2017, 2:15 pm EST

    Thanks Reeva Dhingra,

      I could see the characters getting trimmed properly after setting General Celltypes wordwrap = true. But the header text is getting little aligned top. Also if i increase the height of the column header, i could see the complete text, which is not similar to VB spread.

     

    Thanks,

    Prabhu R 

     

  • Replied 8 September 2017, 2:15 pm EST

    Prabhu,

    Yes, you are right the header text is getting little top aligned. I will report your issue as a bug in Spread. However, as a workaround you can try something like this also:-

                string Mylabel = "Comments";
                fpSpread1.ActiveSheet.SetColumnLabel(0, 1, Mylabel.Substring(0, 1));
                fpSpread1.ActiveSheet.Columns[1].HorizontalAlignment = FarPoint.Win.Spread.CellHorizontalAlignment.Center;
                fpSpread1.ActiveSheet.SetColumnWidth(1, 16);

    Hope it will help you. Thanks.

  • Replied 8 September 2017, 2:15 pm EST

    Reeva,


     I'm still on clear on why exactly the StringTrimming routine impacts this. It seems like StringTrimming.Character just ensures that we don't split a letter at the end of the word when we trim something down.


    What we are really interested in, is Center aligned text shifting to Left aligned text when the cell is smaller than the displayed text. 


    Is that something that inherently gets disabled when the .StringTrim isn't set (because of the issue with GDI vs GDI+)? Could setting a default value for .StringTrim within the Farpoint code correct the issue? It doesn't seem like the alignment change should be lost just because we can't specify how we want the string to be trimmed.


    Thanks


    Jason

  • Replied 8 September 2017, 2:15 pm EST

    Hello,

    This bug reported in this thread(#99918711) has come up as intended bug wherein the root cause here is that the cell set with:


                    c.StringTrim = StringTrimming.Character;

     


    This Enum is supported by GDI+ library method but
    isn’t supported by TextRenderer library.
    There is a differences in support for string trim when using
    TextRenderer/GDI instead of Graphics/GDI+? You can have further information here on these two links: 1) http://msdn.microsoft.com/en-us/library/system.drawing.stringtrimming.aspx and 2) http://msdn.microsoft.com/en-us/library/system.windows.forms.textformatflags.aspx.

    Hope this will help you. Thanks.

  • Replied 8 September 2017, 2:15 pm EST

    Thanks Reeva.

    One more question: Does this has anything to do with GDI or GDI+? In our application we set Application.SetCompatibleTextRenderingDefault to false because we decided to use GDI only. Is this going to be a problem?

     

    Thanks,

    Philip 

  • Replied 8 September 2017, 2:15 pm EST

    Reeva,


     So if we can't use StringTrim with the TextRenderer.dll in place, what is the recommended workaround to force the first character to be displayed when the cell is too small to display the full text?

  • Replied 8 September 2017, 2:15 pm EST

    Hello,

    Fetching the one character substring to be displayed in ColumnHeader cell is the only possible solution I see then.

                string Mylabel = "Comments";
                fpSpread1.ActiveSheet.SetColumnLabel(0, 1, Mylabel.Substring(0, 1));
                fpSpread1.ActiveSheet.Columns[1].HorizontalAlignment = FarPoint.Win.Spread.CellHorizontalAlignment.Center;
                fpSpread1.ActiveSheet.SetColumnWidth(1, 16); 

    Thanks.

  • Replied 8 September 2017, 2:15 pm EST

    Philip,

    I don't think so its creating an issue because I didn't use anything like this in my test application and still I was able to replicate the issue.

    Thanks.

  • Replied 8 September 2017, 2:15 pm EST

    Hello,

     

    The root cause here is that the cell was set with :
    c.StringTrim = StringTrimming.Character;

    This Enum is supported by GDI+ library method but isn't supported by TextRenderer library. Between these two libraries, they are not supporting exactly the same for text formatting flags as shown in comparison table below:

    StringFormat Class Versus TextFormatFlags Enumeration
    Member StringFormat Class TextFormatFlags Enumeration
    Type and Value Value
    Alignment StringAlignment.Near Left (TextFormatFlag.Default)
    StringAlignment.Center HorizontalCenter
    StringAlignment.Far Right



    FormatFlags StringFormatFlags.DirectionRightToLeft RightToLeft
    StringFormatFlags.DirectionVertical No Equivalent
    StringFormatFlags.DisplayFormatControl No Equivalent
    StringFormatFlags.FitBlackBox NoPadding
    StringFormatFlags.LineLimit WordBreak | TextBoxControl
    StringFormatFlags.MeasureTrailingSpaces No Equivalent
    StringFormatFlags.NoClip NoClipping
    StringFormatFlags.NoFontFallback No Equivalent
    StringFormatFlags.NoWrap SingleLine
    Default Behavior WordBreak
    HotkeyPrefix HotKeyPrefix.None NoPrefix
    HotKeyPrefix.Show Default Behavior
    HotKeyPrefix.Hide HidePrefix
    LineAlignment StringAlignment.Near Top (TextFormatFlag.Default)
    StringAlignment.Center VerticalCenter
    StringAlignment.Far Bottom
    Trimming StringTrimming.None Default Behavior
    StringTrimming.Character No Equivalent
    StringTrimming.Word No Equivalent
    StringTrimming.EllipsisCharacter EndEllipsis
    StringTrimming.EllipsisWord WordEllipsis
    StringTrimming.EllipsisPath PathEllipsis
    No Equivalent GlyphOverhangPadding (TextFormatFlag.Default)
    No Equivalent ExternalLeading
    No Equivalent Internal
    No Equivalent ModifyString
    No Equivalent NoFullWidthCharacterBreak
    No Equivalent PrefixOnly
    No Equivalent PreserveGraphicsClipping
    No Equivalent PreserveGraphicsTranslateTransform
    No Equivalent LeftAndRightPadding

    Hope this will help you. Thanks.
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels