|
Overview
|
Next |
This library provides document layout and printing facilities for the desktop only.
Within RichTextBoxDesktop.dll for the desktop you will find the following objects.
RichTextBoxDesktop
The RichTextBoxDesktop object encapsulates and provides access to a Windows Forms RichTextBox control. The control has been enhanced with page setup, preview and printing facilities. The code for printing is based upon a Microsoft article in MSDN (Microsoft Developers Network).
Text within the RichTextBoxDesktop may be formatted in terms of font face, script, font size, fore and back colour, bold, italic, underline and strikeout. Lines and paragraphs may be left, right or both left and right indented and bulleted. They may be left, right or centre aligned on the page and paragraphs may have a hanging indent.
Tabs and manual page breaks may be inserted if needed and pagination is automatic at print time.
A Page Setup dialog may be used to set the paper size and the orientation to portrait or landscape. All four margins may be specified. The printed page may be previewed before printing. Note that there is a "feature" in this dialog when the Operating Measurement System is set to metric. This dialog holds margin values as Imperial and on a metric system converts them from Imperial when the dialog opens and back when it closes. The bug is in converting from Imperial when the dialog opens when it seems that it merely muliplies an Imperial inch value by 10 rather than by 25.4. For example setting a margin of 50mm then closing and reopening the dialog will show a margin value of 19.7mm. The 50mm has been correctly converted and saved to an Imperial value of 1.97 inches (and so will print correctly) but has wrongly been re-converted by multiplying by 10 rather than 25.4. From this it can be seen that the default margin of 10mm displayed on the first opening of the dialog was intended to be 1 inch or 25.4mm. This "feature" is inherited by .NET 2.0, presumably to avoid breaking earlier code that works round it but a property to solve the problem was introduced. This property is provided here as PageSetupMetric and by default this library sets it True so the above behaviour will not be seen. To see the above behaviour, or if an Imperial system is having problems with user margin settings, set this property to False. Note that metric margins are not retained entirely accurately owing to the conversion, with limited precision, to and from Imperial units.
Note therefore, from the previous paragraph, that the values for the LeftMargin, RightMargin, TopMargin and BottomMargin properties are always hundreths of an inch, even on a metric system.
It is envisaged that normally a RichTextBoxDesktop object would be hidden and used to build and print a document but there is nothing to stop it being used as a visible control.
No events are provided for the control. If the control is visible and events are required they may be added using the ControlEvents library by the same author.
FontDialog