Page 1 of 2
text format code
Posted: Tue Jul 17, 2012 8:18 am
by maryam
hello,
I wanted to create print grid and build run time report, in a component in the data band, format is number, in c# code I wrote
(t.TextFormat = new Stimulsoft.Report.Components.TextFormats.StiNumberFormatService(3, ".", 0, ",", 3, true, false, " ");)
when i traced my code format was number but in the preview page the this component didn't have number formatting (for example: separator didn't active and show) in the second time, totally if a component full from data band select, the format is ok, but if i have a component in data band, and set format to number and full it by a number manually, format of number doesn't set for this, i use a stitext and in the text editor page i put format detail of number ({Format("{0:N2}", IDENT)}), instead of IDENT i put my manual number in this time in the preview page format of number is set for this component, when search in code page i find this code:
(public void Text1__GetValue(object sender, Stimulsoft.Report.Events.StiGetValueEventArgs e)
{
e.Value = this.Text1.TextFormat.Format(CheckExcelValue(sender, Format("{0:N0}", 44124451215)));
})
when i use this code in c# and call this event in the part of create component, doesn't event and i don't know what am i doing? could you please help me?
Re: text format code
Posted: Tue Jul 17, 2012 1:47 pm
by HighAley
Hello.
We couldn't reproduce your issue.
Please, send us a sample working project with reproduce the issue.
Thank you.
Re: text format code
Posted: Wed Jul 18, 2012 5:39 am
by maryam
i want to create run time report, format of one component in data band is number, in c# i write this code
(t.TextFormat = new Stimulsoft.Report.Components.TextFormats.StiNumberFormatService(3, ".", 0, ",", 3, true, false, " ");)
when trace this code, format of this component is number but when show this report, the number is "123456789" instead of "123,456,789" and number doesn't have separator.
this full code is here:
h = Hdrlbl.Height;
y = DtTaraz.Height;
columnWidth = StiAlignValue.AlignToMaxGrid(Page.Width / GrdBase.Columns.Count, .5, true);
for (int i = 0; i < GrdBase.Columns.Count; i++)
{
//if (GrdBase.Columns.Name != "AccName")
//{
string s = GrdBase.Columns.Name;
StiText f = new StiText(new RectangleD(0, 0, columnWidth, y));
StiText t = new StiText(new RectangleD(0, 0, columnWidth, h));
//t.Width = GrdBase.Columns.Width / 50;
t.Enabled = f.Enabled = GrdBase.Columns.IsVisible;
if (s == "AccCode" || s == "AccName")
{
t.Width = 2 * columnWidth;
f.Width = 2 * columnWidth;
t.HorAlignment = Stimulsoft.Base.Drawing.StiTextHorAlignment.Center;
f.HorAlignment = StiTextHorAlignment.Left;
//t.VertAlignment = StiVertAlignment.right;
//f.VertAlignment = StiVertAlignment.Center;
}
t.Text = GrdBase.Columns.HeaderText;
t.Brush = new Stimulsoft.Base.Drawing.StiSolidBrush(System.Drawing.Color.FromArgb(255, 214, 224, 236));
f.Brush = new Stimulsoft.Base.Drawing.StiSolidBrush(System.Drawing.Color.White);
f.Text = "{Taraz." + DtGrid.Columns.Caption + "}";
t.VertAlignment = StiVertAlignment.Center;
f.VertAlignment = StiVertAlignment.Center;
if (s != "AccCode" && s != "AccName")
{
t.HorAlignment = StiTextHorAlignment.Center;
f.HorAlignment = StiTextHorAlignment.Center;
}
t.DockStyle = StiDockStyle.Right;
f.DockStyle = StiDockStyle.Right;
if (i == 0)
{
t.Border = new Stimulsoft.Base.Drawing.StiBorder(Stimulsoft.Base.Drawing.StiBorderSides.Left, System.Drawing.Color.Black, 1, Stimulsoft.Base.Drawing.StiPenStyle.Solid, false, 1, new Stimulsoft.Base.Drawing.StiSolidBrush(System.Drawing.Color.White));
f.Border = new Stimulsoft.Base.Drawing.StiBorder(Stimulsoft.Base.Drawing.StiBorderSides.Left, System.Drawing.Color.Black, 1, Stimulsoft.Base.Drawing.StiPenStyle.Solid, false, 1, new Stimulsoft.Base.Drawing.StiSolidBrush(System.Drawing.Color.White));
}
if (i == GrdBase.Columns.Count - 1)
{
t.Border = new Stimulsoft.Base.Drawing.StiBorder(Stimulsoft.Base.Drawing.StiBorderSides.Right, System.Drawing.Color.Black, 1, Stimulsoft.Base.Drawing.StiPenStyle.Solid, false, 1, new Stimulsoft.Base.Drawing.StiSolidBrush(System.Drawing.Color.White));
f.Border = new Stimulsoft.Base.Drawing.StiBorder(Stimulsoft.Base.Drawing.StiBorderSides.Right, System.Drawing.Color.Black, 1, Stimulsoft.Base.Drawing.StiPenStyle.Solid, false, 1, new Stimulsoft.Base.Drawing.StiSolidBrush(System.Drawing.Color.White));
}
if (i != 0 && i != GrdBase.Columns.Count - 1)
{
t.Border = new Stimulsoft.Base.Drawing.StiBorder(Stimulsoft.Base.Drawing.StiBorderSides.All, System.Drawing.Color.Black, 1, Stimulsoft.Base.Drawing.StiPenStyle.Solid, false, 1, new Stimulsoft.Base.Drawing.StiSolidBrush(System.Drawing.Color.White));
f.Border = new Stimulsoft.Base.Drawing.StiBorder(Stimulsoft.Base.Drawing.StiBorderSides.All, System.Drawing.Color.Black, 1, Stimulsoft.Base.Drawing.StiPenStyle.Solid, false, 1, new Stimulsoft.Base.Drawing.StiSolidBrush(System.Drawing.Color.White));
}
t.TextOptions = new Stimulsoft.Base.Drawing.StiTextOptions(true, false, true, 0F, System.Drawing.Text.HotkeyPrefix.None, System.Drawing.StringTrimming.None);
f.TextOptions = new Stimulsoft.Base.Drawing.StiTextOptions(true, false, true, 0F, System.Drawing.Text.HotkeyPrefix.None, System.Drawing.StringTrimming.None);
t.Font = clGlobal.FontObj;
f.Font = clGlobal.FontObj;
t.Alias = GrdBase.Columns.Name;
f.Alias = GrdBase.Columns.Name;
Hdrlbl.Components.Add(t);
DtTaraz.Components.Add(f);
f.TextFormat = new Stimulsoft.Report.Components.TextFormats.StiNumberFormatService(3, ".", 0, ",", 3, true, false, " "); }
Re: text format code
Posted: Fri Jul 20, 2012 8:15 am
by HighAley
Hello.
The formating depends on the data type. If it's numeric then it works right but doesn't work for string.
Please, look at the attached report template.
Thank you.
Re: text format code
Posted: Mon Jul 23, 2012 7:23 am
by maryam
thanks a lot for your answer, now i want to add an image from c# to report, my code is here,
Code: Select all
if (!(ClGlobal.dtCompanyInfo.Rows[0]["CompanyLogo"] is DBNull))
{
byte[] imageData =
(byte[])ClGlobal.dtCompanyInfo.Rows[0][3];
//Initialize image variable
Image newImage;
//Read image data into a memory stream
using (MemoryStream ms = new MemoryStream(imageData, 0, imageData.Length))
{
ms.Write(imageData, 0, imageData.Length);
//Set image variable value using memory stream.
newImage = Image.FromStream(ms, true);
}
((StiImage)PHTotal.Components["Image1"]).Image = newImage;
}
when trace this code i have an error "A generic error occurred in GDI+."
when visit this line "report.Show();"
and i have another problem, iwant to use variable in the data set, datatable datasource but i can't do this.
i don't know what am i doing, could you please help me?
Re: text format code
Posted: Mon Jul 23, 2012 2:13 pm
by HighAley
maryam wrote:thanks a lot for your answer, now i want to add an image from c# to report, my code is here,
when trace this code i have an error "A generic error occurred in GDI+."
Please, try to add next code:
Code: Select all
ms.Write(imageData, 0, imageData.Length);
ms.Seek(0, SeekOrigin.Begin); // Set the stream position to the beginning of the file.
//Set image variable value using memory stream.
newImage = Image.FromStream(ms, true);
maryam wrote:when visit this line "report.Show();"
and i have another problem, iwant to use variable in the data set, datatable datasource but i can't do this.
i don't know what am i doing, could you please help me?
We couldn't understand your problem.
Please, describe it more detailed.
Thank you.
Re: text format code
Posted: Tue Jul 24, 2012 8:50 am
by maryam
i want to filter my data table with Stimulsoft's variable but my data source is data set data table and doesn't support varible and i can't filter could you please help me?
Re: text format code
Posted: Wed Jul 25, 2012 8:14 am
by HighAley
Hello.
Please, send us your report template with data for analysis.
Thank you.
Re: text format code
Posted: Thu Jul 26, 2012 4:29 am
by maryam
aleksey wrote
Please, try to add next code:
Code: Select all
ms.Write(imageData, 0, imageData.Length);
ms.Seek(0, SeekOrigin.Begin); // Set the stream position to the beginning of the file.
//Set image variable value using memory stream.
newImage = Image.FromStream(ms, true);
I added this code in the desgin i had image but in report.show(); i had same error.
Re: text format code
Posted: Thu Jul 26, 2012 2:15 pm
by HighAley
Hello.
maryam wrote:I added this code in the desgin i had image but in report.show(); i had same error.
Please, describe your issue with report.show(); more detailed and
send us your report template with data for analysis.
Thank you.