ASPForums.Net RSS Feedhttp://www.aspforums.net/Handlers/RSS.ashxLatest additions to the content that appears on ASPForums.Net(c) 2019 www.aspforums.com. All rights reserved.Change ASP.Net RDLC Report Font size based on text length using C# and VB.Net<p>Hi <a class="username" rel="akhter"> akhter</a>,</p> <p>Refer below below steps to perform your action.</p> <p>First go to report designing and Right Click on field you want to change the font size.</p> <p><img src="https://i.imgur.com/5Ia6sct.jpg" alt="" width="469" height="269" /></p> <p>Then click on <span style="text-decoration: underline;">TextBox Properties</span> will open textbox property window and click on <span style="text-decoration: underline;">Font</span> tab after that click on&nbsp;Size expression(<span style="text-decoration: underline;">fx</span>).</p> <p><img src="https://i.imgur.com/m2VYL02.jpg" alt="" width="573" height="304" /></p> <p>The expression window will be open there you have write the expression.</p> <pre class="brush: vb">=iif(len(Fields!Address.Value) &gt; 20, &#34;8pt&#34;, &#34;12pt&#34;)</pre> <p><img src="https://i.imgur.com/1hGiiCJ.jpg" alt="" width="545" height="187" /></p> <p><span style="text-decoration: underline;"><strong>Database</strong></span></p> <p>For this example I have used of Northwind database that you can download using the link given below.</p> <p><a href="https://www.aspsnippets.com/Articles/Install-Microsoft-Northwind-and-Pubs-Sample-databases-in-SQL-Server-Management-Studio.aspx" target="_blank">Download Northwind Database</a></p> <p><span style="text-decoration: underline;"><strong>HTML</strong></span></p> <pre class="brush: html">&lt;asp:ScriptManager runat=&#34;server&#34; /&gt; &lt;rsweb:ReportViewer ID=&#34;ReportViewer1&#34; runat=&#34;server&#34; Width=&#34;400px&#34;&gt; &lt;/rsweb:ReportViewer&gt;</pre> <p><span style="text-decoration: underline;"><strong>Namespaces</strong></span></p> <p><strong>C#</strong></p> <pre class="brush: csharp">using System.Configuration; using System.Data.SqlClient; using Microsoft.Reporting.WebForms;</pre> <p><strong>VB.Net</strong></p> <pre class="brush: vb">Imports Microsoft.Reporting.WebForms Imports System.Data.SqlClient</pre> <p><span style="text-decoration: underline;"><strong>Code</strong></span></p> <p><strong>C#</strong></p> <pre class="brush: csharp">protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { ReportViewer1.ProcessingMode = ProcessingMode.Local; ReportViewer1.LocalReport.ReportPath = Server.MapPath(&#34;~/Report.rdlc&#34;); Employees dsEmployees = GetData(&#34;SELECT * FROM Employees&#34;); ReportDataSource datasource = new ReportDataSource(&#34;DataSet1&#34;, dsEmployees.Tables[0]); ReportViewer1.LocalReport.DataSources.Clear(); ReportViewer1.LocalReport.DataSources.Add(datasource); } } private Employees GetData(string query) { string conString = ConfigurationManager.ConnectionStrings[&#34;constr&#34;].ConnectionString; SqlCommand cmd = new SqlCommand(query); using (SqlConnection con = new SqlConnection(conString)) { using (SqlDataAdapter sda = new SqlDataAdapter()) { cmd.Connection = con; sda.SelectCommand = cmd; using (Employees dsEmployees = new Employees()) { sda.Fill(dsEmployees, &#34;DataTable1&#34;); return dsEmployees; } } } }</pre> <p><strong>VB.Net</strong></p> <pre class="brush: vb">Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load If Not IsPostBack Then ReportViewer1.ProcessingMode = ProcessingMode.Local ReportViewer1.LocalReport.ReportPath = Server.MapPath(&#34;~/Report.rdlc&#34;) Dim dsEmployees As Employees = GetData(&#34;SELECT * FROM Employees&#34;) Dim datasource As ReportDataSource = New ReportDataSource(&#34;DataSet1&#34;, dsEmployees.Tables(0)) ReportViewer1.LocalReport.DataSources.Clear() ReportViewer1.LocalReport.DataSources.Add(datasource) End If End Sub Private Function GetData(ByVal query As String) As Employees Dim conString As String = ConfigurationManager.ConnectionStrings(&#34;constr&#34;).ConnectionString Dim cmd As SqlCommand = New SqlCommand(query) Using con As SqlConnection = New SqlConnection(conString) Using sda As SqlDataAdapter = New SqlDataAdapter() cmd.Connection = con sda.SelectCommand = cmd Using dsEmployees As Employees = New Employees() sda.Fill(dsEmployees, &#34;DataTable1&#34;) Return dsEmployees End Using End Using End Using End Function</pre> <p><span style="text-decoration: underline;"><strong>Screenshot</strong></span></p> <p><img src="https://i.imgur.com/cceZICJ.jpg" alt="" width="391" height="461" /></p>https://www.aspforums.net:443/Threads/402162/Change-ASPNet-RDLC-Report-Font-size-based-on-text-length-using-C-and-VBNet/https://www.aspforums.net:443/Threads/402162/Change-ASPNet-RDLC-Report-Font-size-based-on-text-length-using-C-and-VBNet/Fri, 26 Apr 2019 04:30:21 GMT