views:

241

answers:

2

Hi, 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
+2  A: 

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

Ruben
But, I don't really specify RichTextBox.Text at all. It's just automated. The RichTextBox is databinded to the column of the database. How can I specify how to store the rfp property of the rich textbox? I've updated the first post so you can see how I store to the database. And also how I insert into the rich text box.
Kenny Bones
A: 

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

JamesMLV
I'm pretty sure there isn't any property like that. I did however manage to alter which property is binded via the designer.vb. I just searched for the name of the control and found the one regarding databinding. But I get an error saying that the cell in the database is limited to 100 characters, although I've set the limit to 1000. But that's probably a different problem anyway. Think I'll say this quesion is closed for now, thank you :)
Kenny Bones