how i can print label in c# with devexpress
i want to print label from number to another number like
for example -> from number 15 to number 35 with ( Number of count)
please how can i do it ?!!
how i can print label in c# with devexpress
i want to print label from number to another number like
for example -> from number 15 to number 35 with ( Number of count)
please how can i do it ?!!
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Naimish MakwanaRank #324 · 7.7K reputationPosted Mar 26, 2024, 12:56 AM EDT
Sure, you can print labels from a specific number to another number using DevExpress in C#. Here’s a basic example of how you can do it:
// Assuming you have a DevExpress label control named "labelControl" for (int i = 15; i <= 35; i++) { labelControl.Text += i.ToString() + "\n"; }This code will print numbers from 15 to 35 on the DevExpress label control1.
If you want to print these numbers on a physical printer, you can use the
PrintingSystemclass from DevExpress. Here’s a basic example:using DevExpress.XtraPrinting; // ... // Create a new Printing System. PrintingSystem ps = new PrintingSystem(); // Create a new link that will print a label for each number. PrintableComponentLink link = new PrintableComponentLink(ps); // Generate the document. link.CreateDocument(); // Show the print preview. link.ShowPreview();In this code, replace
PrintableComponentLinkwith the actual component you want to print1. Please note that this is a simplified example and you might need to adjust it according to your specific requirements1.Thanks
Jayraj ChhayaRank #304 · 8.2K reputationPosted Mar 27, 2024, 5:14 AM EDT
Hi,
To print labels in C# using DevExpress, you can utilize the DevExpress XtraReports suite for reporting functionality. Here's a simple example to achieve printing labels from number 15 to number 35 with a specified count:
using DevExpress.XtraReports.UI; using System; public void PrintLabels() { int startNumber = 15; int endNumber = 35; int count = 5; // Number of labels to print XtraReport report = new XtraReport(); for (int i = startNumber; i <= endNumber; i++) { for (int j = 0; j < count; j++) { XRLabel label = new XRLabel(); label.Text = $"Label {i}"; report.Bands[BandKind.Detail].Controls.Add(label); } } report.ShowPreview(); }Tuhin PaulRank #7 · 71.9K reputationPosted Mar 26, 2024, 7:36 AM EDT
using DevExpress.XtraReports.UI; using System; using System.Data; namespace YourNamespace { public class LabelPrinter { public void PrintLabels(int startNumber, int endNumber) { // Create a new XtraReport XtraReport report = new XtraReport(); // Design the layout of the report in the designer or programmatically // (You can customize the report layout in the XtraReport designer) // Bind data to the report DataTable dt = GenerateLabelData(startNumber, endNumber); // Assign the data source to the report report.DataSource = dt; // Show the report preview ReportPrintTool printTool = new ReportPrintTool(report); printTool.ShowPreview(); } private DataTable GenerateLabelData(int startNumber, int endNumber) { // Create a DataTable to hold label numbers DataTable dt = new DataTable(); dt.Columns.Add("LabelNumber", typeof(int)); // Generate labels for the range of numbers (from startNumber to endNumber) for (int i = startNumber; i <= endNumber; i++) { dt.Rows.Add(i); } return dt; } } class Program { static void Main(string[] args) { // Example usage: LabelPrinter labelPrinter = new LabelPrinter(); labelPrinter.PrintLabels(15, 35); } } }