Question

I've created a rich text box which stored the "textBox.Text" value in an SDF database. The storing works, but the formatting seems to be lost. Is this something that SDF databases can't handle? Do I need to store in binary or something? Not sure how to do that either.

I'm using Visual Basic Express Edition with Winforms and writing in VisualBasic.NET btw

This is how I store to the database:

Private Sub btnToolStripSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnToolStripSave.Click
    Try
        Me.Validate()
        Me.SangerBindingSource.EndEdit()
        Me.SangerTableAdapter.Update(Me.MusicBaseDBDataSet.Sanger)
        Me.MusicBaseDBDataSet.Sanger.AcceptChanges()

    Catch ex As Exception
        MsgBox(ex.Message)
    End Try
End Sub

And this is how I insert the text in to the rich textbox

txtBoxText.SelectionFont = New Font("Verdana", 16, FontStyle.Bold)
txtBoxText.SelectionColor = System.Drawing.Color.RoyalBlue

txtBoxText.SelectionLength = 0
txtBoxText.SelectedText = btnA.Text & btnB.Text & "   "

txtBoxText.SelectionFont = New Font("Verdana", 12, FontStyle.Regular)
txtBoxText.SelectionColor = System.Drawing.Color.Black

No correct solution

OTHER TIPS

Don't use the RichTextBox.Text property: that removes the formatting. Use the RichTextBox.Rtf property.

Go to the properties of txtBoxText. After expanding the (DataBindings) element, you should be able to change the binding from the Text property to Rtf

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top