RDLC Report Viewer Text not autosizing correctly when displaymode is normal c# WinForms

nerjuner 96 Reputation points
2021-10-24T03:16:24.07+00:00

While Using the RDLC report viewer, The report text does not autosize correctly resulting in some report contents being truncated. On the other had, the Report borders autosize correctly and reposition to fit the (would-be) new report text positions causing the borders to incorrectly draw over the text.

143191-report-with-issue-normal-preview.png

This weird behaviour disappears when I change the report display mode to printLayout (i.e reportViewer1.SetDisplayMode(DisplayMode.PrintLayout); )
and resurfaces when the print layoutmode changes back to normal (i.e reportViewer1.SetDisplayMode(DisplayMode.Normal);` ).

143165-correct-text-auto-sizing-print-preview-mode.png

Am using Visual studio 2019, and version 150.1484.0 of the Microsoft.ReportingServices.ReportViewerControl.Winforms nuget.

Thanks in advance.

Windows Forms
Windows Forms
A set of .NET Framework managed libraries for developing graphical user interfaces.
1,828 questions
SQL Server Reporting Services
SQL Server Reporting Services
A SQL Server technology that supports the creation, management, and delivery of both traditional, paper-oriented reports and interactive, web-based reports.
2,798 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,237 questions
{count} votes

Accepted answer
  1. nerjuner 96 Reputation points
    2021-11-03T03:22:44.76+00:00

    I later discovered it was an issue originating from the general DPI settings of my windows form application because of working on a machine with a higher DPI setting (125% in mycase).

    I fixed it by making the following changes to the form that starts the application;

    1. Go the the Forms designer, then select your Form (by clicking at its title bar)
    2. Press F4 to open the Properties window,
    3. then locate the AutoScaleMode property
    4. Change it from Font (default) to Dpi.

    Then In the program.cs, I modified the code to look as below

    namespace myApplication
    {
        static class Program
        {
            [STAThread]
            static void Main()
            {
                // ***this line is added***
                if (Environment.OSVersion.Version.Major >= 6)
                    SetProcessDPIAware();
    
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new MainForm());
            }
    
            // ***also dllimport of that function***
            [System.Runtime.InteropServices.DllImport("user32.dll")]
            private static extern bool SetProcessDPIAware();
        }
    }
    

    Credit: Stack overflow page with details is here

    0 comments No comments

0 additional answers

Sort by: Most helpful