How should I change the TextFormat of Text as Date format
Posted: Wed Aug 01, 2007 9:27 am
I need to change the TextFormat of text as a Date format at runtime, how should I do this ? Give me code
Reporting tool and data analytics tools for creating reports and dashboards in ASP.NET, ASP.NET MVC, .NET Core, Blazor, Angular, PHP, Python, WPF, JavaScript, and Java applications.
https://forum.stimulsoft.com/
Code: Select all
Stimulsoft.Report.StiReport report = new Stimulsoft.Report.StiReport();
//Create Text Component to Display my Value
Stimulsoft.Report.Components.StiText myTextComp = new Stimulsoft.Report.Components.StiText(new Stimulsoft.Base.Drawing.RectangleD(5, 5, 5, 2));
//Use a Variable to Demonstrate Formatting
report.Dictionary.Variables.Add("MyDate", typeof(DateTime));
report.Dictionary.Variables["MyDate"].ValueObject = DateTime.Now;
//Use My Variable in the Text Component
myTextComp.Text = new Stimulsoft.Report.Components.StiExpression("{MyDate}");
//Set the Formatting for the Text Component
myTextComp.TextFormat = new Stimulsoft.Report.Components.TextFormats.StiDateFormatService("dd MMM yyyy", String.Empty);
//myTextComp.TextFormat = new Stimulsoft.Report.Components.TextFormats.StiDateFormatService("d", String.Empty);
//Add Text Component to my Page and Compile/Render
report.Pages[0].Components.Add(myTextComp);
report.Compile();
report.Show();
Code: Select all
StiComponentsCollection comps = report.GetComponents();
foreach (StiComponent comp in comps)
{
StiText text = comp as StiText;
if (text != null)
{
//At this place you can use code which provide for you Brendan (Thanks)
}
}