Vertical text alignment formatting

Posted by: sstoecker on 18 June 2020, 11:57 pm EST

    • Post Options:
    • Link

    Posted 18 June 2020, 11:57 pm EST - Updated 30 September 2022, 8:07 am EST

    I have a report that requires dynamic columns, and I generating the report with code. A particular sticking point is vertically aligning the columns. I would like the columns to be wider (like the bottom part of the image), giving it the sold block of color look, but when I expand the width, the text gets a bit wonky, breaking apart instead of staying in a single line (like in the top part of the image).

    This is the code I am using, which I found online:

    for (int i = 0; i < dt.Columns.Count; i++)

    {

    columnName = dt.Columns[i].ColumnName.Replace(" “,”_");

    ctl = new GrapeCity.ActiveReports.SectionReportModel.TextBox();

    var _with1 = ctl;

    _with1.Name = columnName;

    _with1.Text = dt.Columns[i].ColumnName;

    _with1.Location = new PointF((0.3f * i) + 1.7f, 0.1f);

    _with1.Size = new SizeF(0.3f, 1.3f);

    _with1.Border.BottomStyle = GrapeCity.ActiveReports.BorderLineStyle.Solid;

    _with1.VerticalText = true;

    _with1.BackColor = System.Drawing.Color.Green;

    _with1.ForeColor = System.Drawing.Color.White;

    ar.Sections[0].Controls.Add(ctl);

    }

    Also, text is being split oddly. As you can see in the image:

    • ““Bed Rail” becomes “Bed R ail”

      “Call Light” becomes “C allLi ght”

      “OR Lamp Arm” becomes “O R Lam p Arm””

    Do you have suggestions on how I may fix this?

    Thank you,

    Scott

  • Posted 21 June 2020, 5:54 pm EST

    Hello,

    Can you please try after increasing little bit width of TextBox.

    Thanks,

    Mohit

  • Posted 22 June 2020, 10:14 pm EST

    Thank you. Expanding the column width doesn’t seem to fix the problem. If I set the cell alignment to Horizontal, the spacing issues go away, but the text isn’t vertical.

  • Posted 24 June 2020, 10:31 pm EST

    Hello,

    Could you please check with the attached report and see the gap changes with the respect of the width.

    Also, please share the own report so that I can replicate the issue at my end.

    Thanks,

    Mohit

    tested.zip

  • Posted 25 June 2020, 1:45 am EST - Updated 30 September 2022, 8:07 am EST

    The report is completely code-based. I created it this way because, as far as I know, I needed to in order to create a report with a dynamic number of columns. (If there is a different way, I’d be happy to know it - it would probably be better than doing it in code.) But because of that, there are no controls defined in the report file - it’s all C# code.

    Here is the relevant section of code that creates the vertical text headers. If you are able to write code that basically does what you can in the RDL file, that would be great - my attempts have failed.

    GrapeCity.ActiveReports.SectionReport ar = default(GrapeCity.ActiveReports.SectionReport);

    DataTable dt = ReturnReportData(FileName);

    GrapeCity.ActiveReports.SectionReportModel.TextBox ctl = default(GrapeCity.ActiveReports.SectionReportModel.TextBox);

    for (int i = 0; i < dt.Columns.Count; i++)

    {

    columnName = dt.Columns[i].ColumnName.Replace(" “,”_");

    ctl = new GrapeCity.ActiveReports.SectionReportModel.TextBox();
    ctl.Name = columnName;
    ctl.Text = dt.Columns[i].ColumnName;
    ctl.Location = new PointF((0.3f * i) + 1.7f, 0.4f);
    ctl.Size = new SizeF(0.3f, 1.0f);
    
    ctl.Border.BottomStyle = GrapeCity.ActiveReports.BorderLineStyle.Solid;
    ctl.Border.RightStyle = GrapeCity.ActiveReports.BorderLineStyle.Solid;
    ctl.VerticalText = true;
    ctl.VerticalAlignment = GrapeCity.ActiveReports.Drawing.VerticalTextAlignment.Middle;
    ctl.BackColor = System.Drawing.Color.FromArgb(111, 162, 135);
    ctl.ForeColor = System.Drawing.Color.White;
    ctl.Font = font;
    

    if (i == 0)

    {

    ctl.Border.LeftStyle = GrapeCity.ActiveReports.BorderLineStyle.Solid;

    }

    ar.Sections[0].Controls.Add(ctl);

    }

    I have also included an image some experimentation that I did where, though it didn’t quite turn out the way I wanted. I want the green background to be solid across all the columns - no white in between them - but if I make the size wider, the characters spread out and looks weird. I would prefer the letters to turn sideways as in my original example, but at this point, as long the lettering is correct, I’d be happy.

  • Posted 25 June 2020, 1:49 am EST

    Another thought: Is there a way to create some kind of “background control” that sits underneath the TextBox? I’m thinking that if I keep the TextBox this size, but create some kind of background color with the correct width (solid green instead of white between the TextBoxes), it would look the way I would like. The TextBox would just contain the text, and the background would hold the color I need.

  • Posted 25 June 2020, 5:00 am EST

    I found a solution. I converted the TextBox to a Label, set the Angle to 2700, and the horizontal alignment to “Right”:

    ctl = new GrapeCity.ActiveReports.SectionReportModel.Label();
    ctl.Angle = 2700;
    ctl.Alignment = GrapeCity.ActiveReports.Drawing.TextAlignment.Right;
    
  • Posted 26 June 2020, 1:15 am EST

    Hello,

    I am glad that your issue is solved now. Please let me know if you have any questions.

    Thanks,

    Mohit

Need extra support?

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

Learn More

Forum Channels