Change date format dynamically and set UpperCase
Posted: Thu May 05, 2011 4:23 pm
Hi
Is there a easy way to both set date format and make a data field upper case dynamically.
I change the date format depending on what the user decides, and normally this is the format ddMMMyy e.g. 01MAY11, but it always becomes 01may11
Can i some way also do uppercase, I have tried to do upper case in the data field directly in the desinger, but it doesnt work
Im looping thorugh my fields like this so set the date format, but I cant get it to uppercase
public static void CheckComponents(Stimulsoft.Report.Components.StiComponentsCollection comps, string longdateformat, string shortdateformat,string timeformat, Stimulsoft.Report.StiReport rpt)
{
foreach (Stimulsoft.Report.Components.StiComponent c in comps)
{
if (c is Stimulsoft.Report.Components.StiContainer)
{
Stimulsoft.Report.Components.StiContainer cont = (Stimulsoft.Report.Components.StiContainer)c;
CheckComponents(cont.Components, longdateformat, shortdateformat,timeformat,rpt);
}
if (c is Stimulsoft.Report.Components.StiText)
{
Stimulsoft.Report.Components.StiText t = (Stimulsoft.Report.Components.StiText)c;
if (t.Name.Length > 8)
{
if (t.Name.Substring(0, 8) == "DateText")
t.TextFormat = new Stimulsoft.Report.Components.TextFormats.StiDateFormatService(shortdateformat, String.Empty);
else if (t.Name.Substring(0, 8) == "DaTmText")
t.TextFormat = new Stimulsoft.Report.Components.TextFormats.StiDateFormatService(longdateformat, String.Empty);
else if (t.Name.Substring(0, 8) == "TimeText")
t.TextFormat = new Stimulsoft.Report.Components.TextFormats.StiDateFormatService(timeformat, String.Empty);
}
}
}
Is there a easy way to both set date format and make a data field upper case dynamically.
I change the date format depending on what the user decides, and normally this is the format ddMMMyy e.g. 01MAY11, but it always becomes 01may11
Can i some way also do uppercase, I have tried to do upper case in the data field directly in the desinger, but it doesnt work
Im looping thorugh my fields like this so set the date format, but I cant get it to uppercase
public static void CheckComponents(Stimulsoft.Report.Components.StiComponentsCollection comps, string longdateformat, string shortdateformat,string timeformat, Stimulsoft.Report.StiReport rpt)
{
foreach (Stimulsoft.Report.Components.StiComponent c in comps)
{
if (c is Stimulsoft.Report.Components.StiContainer)
{
Stimulsoft.Report.Components.StiContainer cont = (Stimulsoft.Report.Components.StiContainer)c;
CheckComponents(cont.Components, longdateformat, shortdateformat,timeformat,rpt);
}
if (c is Stimulsoft.Report.Components.StiText)
{
Stimulsoft.Report.Components.StiText t = (Stimulsoft.Report.Components.StiText)c;
if (t.Name.Length > 8)
{
if (t.Name.Substring(0, 8) == "DateText")
t.TextFormat = new Stimulsoft.Report.Components.TextFormats.StiDateFormatService(shortdateformat, String.Empty);
else if (t.Name.Substring(0, 8) == "DaTmText")
t.TextFormat = new Stimulsoft.Report.Components.TextFormats.StiDateFormatService(longdateformat, String.Empty);
else if (t.Name.Substring(0, 8) == "TimeText")
t.TextFormat = new Stimulsoft.Report.Components.TextFormats.StiDateFormatService(timeformat, String.Empty);
}
}
}