Hallo,
ich habe Erfahrung mit Dynamics NAV und L&L aber das ist das erste mal, dass ich etwas mit C# und L&L mache und ich habe ein paar Fragen. Also ich will ein C# Programm machen mit Custom Fields, d.h. ich brauche keine Datenquelle (alles wird zur Zeit hard coded). Als ich verstanden habe ohne DataSource geht das nicht (?) und deswegen habe ich eine einfache Liste<> erstellt nur dass es eine Datenquelle gibt. L&L Projektdatei habe ich schon erstellt. Hier ist der Code:
[code]namespace Test
{
public partial class Form1 : Form
{
combit.ListLabel22.ListLabel LL;
public Form1()
{
InitializeComponent();
}
private void btnDesigner_Click(object sender, EventArgs e)
{
try
{
PrepareLL();
bool ShowProjectFileSelector = false;
LL.Design("LuL Project", LlProject.List, LL.AutoProjectFile, ShowProjectFileSelector);
}
catch (Exception LlException)
{
MessageBox.Show(LlException.Message);
}
}
private void btPrint_Click(object sender, EventArgs e)
{
PrepareLL();
bool ShowPrintOptions = false;
bool ShowProjectFileSelector = false;
try
{
LL.Print(LlProject.List, LL.AutoProjectFile, ShowProjectFileSelector, LlPrintMode.Preview, LlBoxType.None, "LL-Preview", ShowPrintOptions, @"C:\TEMP");
}
catch (ListLabelException ex)
{
MessageBox.Show(ex.Message);
}
LL.Dispose();
}
void PrepareLL()
{
LL.Variables.Add("Global.DebugMode", 0);
LL.Variables.Add("Global.ReportDescription", "Name");
LL.Variables.Add("Global.ReportName2", "Date Filter");
LL.Variables.Add("Global.ReportName3", "ReportName3");
LL.Variables.Add("Global.UserID", "UserName");
LL.Variables.Add("Global.Date", DateTime.Now.ToString("dd.MM.yyyy"));
LL.Variables.Add("Global.PrintTime", DateTime.Now.ToString("dd.MM.yyyy hh:mm:ss tt"));
LL.Variables.Add("Global.Company", "COMPANYNAME");
LL.AutoDefineNewLine += new AutoDefineNewLineHandler(LL_AutoDefineNewLine);
List<DataSource> dataSource = new List<DataSource>();
dataSource.Add(new DataSource { Text1 = "Test1", Number1 = 1 });
dataSource.Add(new DataSource { Text1 = "Test2", Number1 = 2 });
LL.DataSource = dataSource;
LL.AutoProjectType = LlProject.List;
LL.AutoProjectFile = @"C:\Users\Name\Desktop\file.lst";
}
public class DataSource
{
public string Text1 { get; set; }
public double Number1 { get; set; }
}
void LL_AutoDefineNewLine(object sender, AutoDefineNewLineEventArgs e)
{
LL.Fields.Add("Global.Account", "A. 1. Account");
LL.Fields.Add("Global.Accountgroup", "I. Group");
LL.Fields.Add("Global.Category", "1.Category");
LL.Fields.Add("Global.Name", "testName");
LL.Fields.Add("Global.year", 500);
LL.Fields.Add("Global.year in %", "10");
LL.Fields.Add("Global.previous year", 1000);
LL.Fields.Add("Global.previous year in %", "15");
LL.Fields.Add("Global.Sum", 4545122);
LL.Fields.Add("Global.Sum in %", "17");
LL.Fields.Add("Global.Sum Vorjahr", 18525);
LL.Fields.Add("Global.Sum Vorjahr in %", "18");
}
}
}
[/code]
Im Designer sehe ich alle Felder mit entsprechenden Werten aus LL_AutoDefineNewLine Funktion und der Designer meldet auch keine Fehler (Alle Felder sind registriert). Wenn ich es Drucken will (oder Vorschau) dann ist die Tabelle bzw. sind die Felder automatisch weg, alles was ich sehe sind nur Kopf-Variablen und leere Seite. Ich verstehe nicht warum das passiert. Ich bin auch ein newbie mit C# und L&L. Danke für Ihre Hilfe.
LG,
Damir