msgl
asked on
Is it possible to load text in a richtextbox from a dataset?
It doesn't sound to complicated but I haven't found any article or such describing how to do it.
Basically I want to select a template name in a combobox, press a button and fetch selected template to the richtextbox with a web service that executes a stored procedure (sql server)
Does anyone of you have any tips about a useful article?
Thanks in advance.
Basically I want to select a template name in a combobox, press a button and fetch selected template to the richtextbox with a web service that executes a stored procedure (sql server)
Does anyone of you have any tips about a useful article?
Thanks in advance.
http://www.datadynamics.com/Help/ARNET/ActiveReports~DataDynamics.ActiveReports.RichTextBox~ReplaceField.html
ASKER
Hi plusone,
That wasn't exactly what I was looking for. The questions is:
If I have a dataset with data such as template id, template name, template description and template data
how do I load the template data into the richtextbox?
The data is stored as binary data in an image field on the server so I have to convert it to a string
but then? Most of the examples I have seen uses a openfiledialog but that isn't what I am looking for.
Thanks in advance.
That wasn't exactly what I was looking for. The questions is:
If I have a dataset with data such as template id, template name, template description and template data
how do I load the template data into the richtextbox?
The data is stored as binary data in an image field on the server so I have to convert it to a string
but then? Most of the examples I have seen uses a openfiledialog but that isn't what I am looking for.
Thanks in advance.
ASKER
I guess I gave you a bad explanation of what I wanted to do and I will break it down in a few steps.
I have a web service that returns a datatable with selected (from a combobox) template. The datatable has one row with columns id, name, description and data.
I want to assign the data cell to a variable and then convert it from the byte array it is to a string and then load it into the textbox.
My question is how do I get the data cell value into a variable?
I have a web service that returns a datatable with selected (from a combobox) template. The datatable has one row with columns id, name, description and data.
I want to assign the data cell to a variable and then convert it from the byte array it is to a string and then load it into the textbox.
My question is how do I get the data cell value into a variable?
ASKER
Ok I got the cell value and convert it to a string with:
Dim TemplateData As Byte() = TemplateDataTableInstance. Rows(0).It em("Templa teData")
Dim strTemplateData As String
Dim enc As New System.Text.UTF8Encoding()
strTemplateData = enc.GetString(TemplateData )
Now I just need to load the string into the textbox with something like
Dim strDataFormat As String = DataFormats.Rtf
Using ms As New MemoryStream(strTemplateDa ta)
Dim tr As New TextRange(rtbTemplate.Docu ment.Conte ntStart, rtbTemplate.Document.Conte ntEnd)
tr.Load(ms, strDataFormat)
End Using
it breaks on the dim tr as new textrange line though, is it because I use a flowdocument in the richtextbox and how do I fix that?
Dim TemplateData As Byte() = TemplateDataTableInstance.
Dim strTemplateData As String
Dim enc As New System.Text.UTF8Encoding()
strTemplateData = enc.GetString(TemplateData
Now I just need to load the string into the textbox with something like
Dim strDataFormat As String = DataFormats.Rtf
Using ms As New MemoryStream(strTemplateDa
Dim tr As New TextRange(rtbTemplate.Docu
tr.Load(ms, strDataFormat)
End Using
it breaks on the dim tr as new textrange line though, is it because I use a flowdocument in the richtextbox and how do I fix that?
ASKER
I can load the TemplateData as byte() into the richtextbox but not if I convert it to a string,
With byte array I lose the RTF formatting though, any comments?
With byte array I lose the RTF formatting though, any comments?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.