question

nerjuner-2164 avatar image
0 Votes"
nerjuner-2164 asked nerjuner-2164 answered

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

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.









dotnet-csharpsql-server-reporting-serviceswindows-forms
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@nerjuner-2164, based on my test, I could not reproduce your problem. I can get the normal report for PrintLayout and Normal both two models. I recommend that you could update the vs2019 to the latest version to see if it works for you.

1 Vote 1 ·

1 Answer

nerjuner-2164 avatar image
0 Votes"
nerjuner-2164 answered

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


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.