Inserting a Text Frame

A text frame is inserted by first creating an instance of the TextFrame class, and then adding it to the TextFrameCollection:

TXTextControl.TextFrame newFrame = new TXTextControl.TextFrame(new Size(1000,1000));
textControl1.TextFrames.Add (newFrame, TXTextControl.HorizontalAlignment.Left,
[Visual Basic]
Dim NewFrame As New TXTextControl.TextFrame(New Size(1000, 1000))
TextControl1.TextFrames.Add(NewFrame, TXTextControl.HorizontalAlignment.Left, _
    -1, TXTextControl.TextFrameInsertionMode.DisplaceText)
    NewFrame : TXTextControl.TextFrame;
    TextFrameSize : System.Drawing.Size;
    TextFrameSize := System.Drawing.Size.Create(1000, 1000);
    NewFrame := TXTextControl.TextFrame.Create(TextFrameSize);
    TextControl1.TextFrames.Add(NewFrame, TXTextControl.HorizontalAlignment.Left,
         -1, TXTextControl.TextFrameInsertionMode.DisplaceText);

Once a text frame has been inserted, it can be activated by clicking on its border. An activated text frame can be moved and resized by dragging its border with the mouse.

Text Control provides a built-in dialog box for changing the appearance of a text frame. The dialog box is displayed using the TextFrameAttributesDialog method:

[Visual Basic]

The menu item which displays this dialog box should be disabled when no text frame is selected. This can be done in the menu's popup event, using the GetItem method of the TextFrame collection:

mnuTextFrame_Properties.Enabled = (textControl1.TextFrames.GetItem() != null);
[Visual Basic]
mnuTextFrame_Properties.Enabled = Not IsNothing(TextControl1.TextFrames.GetItem())
mnuTextFrame_Properties.Enabled := (TextControl1.TextFrames.GetItem() <> NIL);

Next >>