C# Code |
[Top] [Chapter] [Previous] [Next] |
This C# code uses a loop instead of a database and the event OnFieldGetText is not defined.
// Initialize IWPMemo memo; IWPTextCursor cursor; memo = wpdllInt1.Memo; cursor = memo.TextCursor; memo.RTFDataSelect("@@FIRST@@"); // undoes memo.RTFDataSelect("LABELS") memo.Clear(false, true); IWPCharAttr CurrAttr = memo.CurrAttr;
// Create mailing fields CurrAttr.Clear(); CurrAttr.SetFontSize(10); cursor.InputField("NAME","Name",false); cursor.InputString("\r",0); cursor.InputField("ADR1","Adr1",false); cursor.InputString("\r",0); cursor.InputField("ADR2","Adr2",false); cursor.InputString("\r\r",0); CurrAttr.IncludeStyles(1); // bold cursor.InputField("ZIP","00000",false); cursor.InputString(" ",0); cursor.InputField("CITY","City",false);
// Now merge text text and copy it to a // different text element using RTFDataAppendTo // In this example we just do a loop. Usually // you will scroll through the database in this loop
// Please Note: first merge, then append!
memo.RTFDataDelete("LABELS"); // Clear it for (int i=0; i<30; i++) { memo.MergeText(""); memo.RTFDataAppendTo("LABELS", 1); }
// Select the label sheet // Do it before you configure the label! memo.RTFDataSelect("LABELS");
// Switch off the field markers memo.SpecialTextAttr(SpecialTextSel.wpInsertpoints).Hidden = true;
// Set up the label sheet IWPLabelDef label; label = memo.LabelDef; label.Caption = "WPCubed GmbH * St. Ingbert Str. 30 * 8151 Munich"; label.ColumnCount = 2; label.RowCount = 7; label.Horizontal = 0.5F; // 5 mm between labels label.Vertical = 0.5F; // 5 mm between labels // and display it label.Active = true;
|