onyak
asked on
Convert Text to RichText
Anyone have an idea of how to convert Text to RichText? I'm using the VB.Net RichText control to display and save Text in a SQL Server Database. The text needs to be converted and saved as RichText. Right now, I set the RichTextBox control to the value from the Database but it doesn't display becuase it doesn't have the RTF markup codes.
ASKER
It's nvarchar. And it's stored as Text and RichText. What I need to do is...over time...has the application automatically convert all text to RichText by converting the text to Richtext in the application....unless it's already richtext.
The link you posted did not have the solution.
The link you posted did not have the solution.
ASKER
Found a solution, but it's not the best solution...
Try
rtb.Rtf = rt
Catch
rtb.Rtf = "{\rtf1\ansi\ansicpg1252\d eff0\defla ng1033" & _
"{\fonttbl{\f0\fnil\fchars et0 Microsoft Sans Serif;}}\viewkind4\uc1\" & _
"pard\f0\fs17 " & rt.ToString & "\par}"
End Try
Try
rtb.Rtf = rt
Catch
rtb.Rtf = "{\rtf1\ansi\ansicpg1252\d
"{\fonttbl{\f0\fnil\fchars
"pard\f0\fs17 " & rt.ToString & "\par}"
End Try
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
also maybe look here
https://www.experts-exchange.com/questions/21097261/Need-help-with-notes-field-for-database-application-VB-NET-and-SQL-2000.html?query=richtextbox+sql&topics=866