Page 1 of 1
Returning List of Barcode Types
Posted: Mon Apr 15, 2013 1:08 pm
by SWhitty
Hi,
I would like to place a form onto my report which would list the Barcode types available in the report, upon selecting a barcode type from a Lookup Box on a Form, the barcode type would be altered on the report.
How can I generate the list of Barcode types and what would i need to cast the result into to correctly assign the type to the Barcode on my final report?
Many Thanks
Simon
Re: Returning List of Barcode Types
Posted: Tue Apr 16, 2013 7:03 am
by HighAley
Hello, Simon.
SWhitty wrote:I would like to place a form onto my report which would list the Barcode types available in the report, upon selecting a barcode type from a Lookup Box on a Form, the barcode type would be altered on the report.
How can I generate the list of Barcode types and what would i need to cast the result into to correctly assign the type to the Barcode on my final report?
You can get list of all Bar Code services with next code:
Code: Select all
StiServiceContainer services = StiConfig.Services.GetServices(typeof(StiBarCodeTypeService));
Thank you.
Re: Returning List of Barcode Types
Posted: Tue Apr 16, 2013 4:03 pm
by SWhitty
Thats fantastic, thank you very much.
For anyone reading this in the future:
Code: Select all
using Stimulsoft.Report.BarCodes;
using Stimulsoft.Base.Services;
namespace Reports
{
public class Report : Stimulsoft.Report.StiReport
{
StiServiceContainer services = StiConfig.Services.GetServices(typeof(StiBarCodeTypeService));
private void showBarcodeTypes()
{
foreach (object o in services)
{
rtnstr += rtnstr == "" ? o.ToString() : System.Environment.NewLine + o.ToString();
}
MessageBox.Show(rtnstr);
}
private void setBarcodeType()
{
string selected = "Code11";
foreach (StiBarCodeTypeService s in services)
{
if (s.ToString() == selected)
{
BarCode1.BarCodeType = s;
}
}
}
public Report()
{
this.InitializeComponent();
}
#region StiReport Designer generated code - do not modify
#endregion StiReport Designer generated code - do not modify
}
}
Re: Returning List of Barcode Types
Posted: Wed Apr 17, 2013 5:15 am
by HighAley
Hello.
Thank you for your code.
It will be useful for newcomers.
Do not hesitate to ask other questions.
Thank you.