Retrieving a Record

Windows Presentation Foundation User's Guide > Howto: Connect to Databases

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.

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

    textControl1.Load(sRTFData, TXTextControl.StringStreamType.RichTextFormat);
[Visual Basic]
Private Sub GetRecord()
    Dim sRTFData As String = dsRTFData.Tables(0).Rows(iCurrentRow).ItemArray(0).ToString()

    textControl1.Load(sRTFData, TXTextControl.StringStreamType.RichTextFormat)
End Sub

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.