Retrieving a Record

The TextControl.Load method is used to display RTF formatted text in Text Control 1. As Text Control 2 just displays the RTF source code without any formatting, we can simply use the Text property to load it.

[C#]
private void GetRecord()
{
    string sRTFData = dsRTFData.Tables[0].Rows[iCurrentRow].ItemArray[0].ToString() ;

    textControl1.Load(sRTFData, TXTextControl.StringStreamType.RichTextFormat);
    textControl2.Text = sRTFData;
}
[Visual Basic]
Private Sub GetRecord()
    Dim SRTFData As String = DsRTFData.Tables(0).Rows(ICurrentRow).Item("rtf_item")

    TextControl1.Load(SRTFData, TXTextControl.StringStreamType.RichTextFormat)
    TextControl2.Text = SRTFData
End Sub
[Delphi]
procedure Form1.GetRecord();
var
    sRTFData :String;
begin
    sRTFData := dsRTFData.Tables[0].Rows[iCurrentRow].Item['rtf_item'].ToString;
    TxTextControl1.Load(sRTFData, TXTextControl.StringStreamType.RichTextFormat);
    TxTextControl2.Text := sRTFData;
end;

The text format used in this example is RTF, which has the advantage of being accessible by most word processing programs. If this is not an issue, Text Control's binary format may be a better choice, as it is more compact and will take up less space in a database.

<< Previous