| Skype: | TextControlSupport | |
| Orders: | 877-462-4772 |
This article shows you how to integrate TX Text Control .NET into Delphi 8.0 .NET and above. It describes how to create a simple word processing application from scratch.
After installing TX Text Control using the setup program, start Delphi .NET and create a new project. Select a Delphi for .NET Windows Forms application project.

Then use the Component / Installed .NET components dialog to add TX Text Control .NET to your tool palette. In the .NET Components tab, look for the four TX Text Control .NET components. If you sort the list by Namespace, you will see the 4 components:
Check them and click OK.

After closing the dialog, you will see the four TX Text Control .NET icons in the Tool Palette.

In this step, you put these controls on a form and connect them. Click on the ButtonBar icon and draw it on to the form. Do the same for the other three components. The form should now look like this:

Now set the Dock property to Top for the Button Bar and the Ruler Bar. TX Text Control should be set to Fill and the Status Bar to Bottom.
At this stage, while you can type into TX Text Control, the button bar and the ruler bar cannot be used. They must be connected to TX Text Control in the form's Load event.
procedure TWinForm.TWinForm_Load(sender: System.Object; e: System.EventArgs); begin TextControl1.ButtonBar := ButtonBar1; TextControl1.RulerBar := RulerBar1; TextControl1.StatusBar := StatusBar1; end;
Now start the application by pressing F9 and ensure that the toolbars are connected to TX Text Control.

Now, we will add some menus to call the built-in dialog boxes of TX Text Control .NET.
Drag a MainMenu control on your form and create a Format menu with the items Character... and Paragraph.... Label the items mnuFomat_Character and mnuFormat_Paragraph. Add the following code to the Click procedures of the menu items:
procedure TWinForm.mnuFormat_Paragraph_Click(sender: System.Object; e: System.EventArgs); begin TextControl1.ParagraphFormatDialog; end; procedure TWinForm.mnuFormat_Character_Click(sender: System.Object; e: System.EventArgs); begin TextControl1.FontDialog; end;
Now, create an Edit menu with the items Cut, Copy and Paste. The code for these items is:
procedure TWinForm.mnuEdit_Paste_Click(sender: System.Object; e: System.EventArgs); begin TextControl1.Paste; end; procedure TWinForm.mnuEdit_Copy_Click(sender: System.Object; e: System.EventArgs); begin TextControl1.Copy; end; procedure TWinForm.MenuItem3_Click(sender: System.Object; e: System.EventArgs); begin TextControl1.Cut; end;
After adding these menu items, you will be able to cut, copy or paste text from other applications via the clipboard.
The last menu should implement a simple file menu. Create a File menu with the items Open File... and Save File As... and use the following code:
procedure TWinForm.mnuFile_Save_Click(sender: System.Object; e: System.EventArgs); begin TextControl1.Save; end; procedure TWinForm.mnuFile_Open_Click(sender: System.Object; e: System.EventArgs); begin TextControl1.Load; end;
The Load and Save methods are called without any parameters, so that they automatically open a dialog box for the end user to select the filename and the format. After clicking Open in the dialog, TX Text Control will load the selected file properly.
Please download
[58.3 KB, ZIP] the full source code for this sample.
The minimum requirements for this sample application are TX Text Control .NET trial version and Delphi 8.0 for Microsoft .NET Framework.