Question Rich Text Box Editor Control

dsk96m

Well-known member
Joined
Jan 11, 2013
Messages
173
Programming Experience
1-3
I am looking for a richtextbox editor for windows forms.

Nothing complex - bold, underline, italic, bullets, numbers, font size, etc, the basics.

How do I accomplish this. I can't just add a richtextbox from the toolbox can I? I tried that, there was no editor. I am using visual studio 2010. I pretty much want an editor like the one here when you are creating a new thread or replying to one. I do not need all those options though. Every control or example is for ASP.NET.

Anyone have any suggestions? Thanks
 
The RichTextBox control is about displaying RTF text. If you want a tool bar then create one yourself, i.e. add a ToolStrip, add the appropriate buttons, handle their Click events and then invoke the appropriate members of the RichTextBox. Here's a very old example that uses the old ToolBar control:

RichTextBoxExtended - CodeProject

I found that in about 10 seconds with a web search. The code is in C# but the principles are exactly the same in VB. You could implement basically the same thing in VB with a ToolStrip instead because the RichTextBox control won't have changed at all since then.
 
I know I could create one, but why reinvent the wheel. I know these items exist from doing research. Most are part of software like Infragistics, etc that you have to pay for. So I always ask if anyone has a suggestion. I actually found one, sort of. Had to tweak it some, but I think it is working.

Thanks for the information. Much appreciated.
 
A follow up to this. I added a datasource item as a rich text box to my form. How do i make it so the richtext is saved to the database and not just the string. I need to use richtextbox.rtftext that includes the rtf data. I looked in my table adapter, looked at the parameters, not sure how to make it save the rtftext to the database. Just doing endedit and update all doesnt work. I am looking at the insertcommand of the table adapter, i see the @parameter that i want, just dont know how to send the rtf to that.
Any help would be greatly appreciated.
 
There is no 'rtftext' property. There's a Text property and an Rtf property. Simple binding to any property is exactly the same:
myControl.DataBindings.Add("ControlPropertyName", dataSource, "DataPropertyName")
That's how you bind regardless of the control, the property and the data source.
 
I understand how to do that binding, but where do I do that? I mean I am just using a typed dataset. Do I do that in the on save, do i change the table adapter?

VB.NET:
    Private Sub FlightcardBindingNavigatorSaveItem_Click(sender As System.Object, e As System.EventArgs) Handles FlightcardBindingNavigatorSaveItem.Click
        Me.Validate()
        Me.Aircraft_conditionBindingSource.EndEdit()
        Me.System_setupBindingSource.EndEdit()
        Me.FlightcardBindingSource.EndEdit()
        Me.TableAdapterManager.UpdateAll(Me.FlightTestApp2DataSet)

        Me.TabControl1.TabPages(6).Enabled = False

    End Sub
 
From datasources, i changed the type of the field to rich text box and then added it to the form, so it is bounded
 
Or do i not do it that way, add the richtextbox via the toolbox to the form then in the on load, use the databinding.add
 
"Bounded" is the past tense of "bound", as in "my dog bounded across the garden to greet me". "Bound" is the past tense of "bind", as in "the RichTextBox is bound to the DataTable".

As for the question, if you've dragged the column from the Data Sources window to generate the RichTextBox then you need to check which property is bound. I'm guessing that it will have automatically bound the Text property. If so then you need to remove that binding and add one for the Rtf property instead, or maybe you can edit the existing binding and just change the property. You can use the (DataBindings) node in the Properties window to check and, if required, change.
 
There isn't just Tag and Text. They are the only two common ones but there's an Advanced item that opens a dialogue that displays all explicitly bindable properties. As it turns out though, Rtf is not explicitly bindable so it's not included there either. I assume that that's because it has the Browsable attribute set to False. I just tested binding in code and that worked though, so you can still bind the Rtf property; just not in the designer. You just need to unbind the Text property in the designer and then bind the Rtf property in code.
 
Ok, thanks buddy. I actually found a great free rich text box with editing (TX Text Control Express - free, professional rich text editing), but it doesnt do databinding. I was thinking of trying to use that to make a new control that adds databinding, but that is beyond my knowledge of how to do it.

On a side not, i emailed you about our other post. I think i got it working using some of the code you gave me, but ran into an issue with some of that code. If you check out the email you will see what I mean. I am actually getting one of the child tables to save correctly. Thank you so much for the help with that.
 
Back
Top