Cannot display both byte arrays in Rich TextBox ?Please help!

N

nitin8or

Hi ALL,

I want to display in a RichTextBox the Binary Large Objects data
coming from database. If I have one record its not a problem I convert
it to byte array and pass it on in a stream as a byte array and then
call Loadfile method of RichTextBox and pass the stream. This works
BUT IF

I have more records I have to create a loop and some how pass the
concatenated byte array and then pass it in a stream. I do this with
following code but when I see the RichTextBox I can see only one
Record and not all the records retrieved from database, I think reason
is the that in the stream all different byte arrays have start and end
header and stream shows only till the point it sees end header of
first record. Please help am i moving in right direction or is there
any other solution. Your reply would be highly appreciated. Thanks a
lot.

Here is the code for reference

private void ShowPaketRtfText(long lngPaketID, string strSprachID)
{

byte[] binaryData=null;
DataSet PaketSet = oService.GetPaketTextBlocks(lngPaketID,strSprachID);
DataTable dataTable = PaketSet.Tables[0];
ArrayList pobjCombinedArrays = new ArrayList();
foreach(DataRow Row in dataTable.Rows)
{
binaryData = (byte[])Row["VERSION_TEXT"];
pobjCombinedArrays.AddRange(binaryData);
}

byte[] pbytCombinedArrays = new byte[pobjCombinedArrays.Count];
pobjCombinedArrays.CopyTo(pbytCombinedArrays);

System.IO.MemoryStream stream = new
System.IO.MemoryStream(pbytCombinedArrays);
RTFTextBlock.LoadFile(stream, RichTextBoxStreamType.RichText);
}
 
N

Nicholas Paldino [.NET/C# MVP]

nitin8or,

I believe that this is the case. What you will have to do is append the
text somehow. You could have another RichTextBox that is not visible, load
the contents into that, then get the RTF for that textbox, and append it to
the RTF of the textbox that is being displayed.

Hope this helps.
 
N

nitin8or

Thanks Nikolaus,

I thought of it too and its working fine, but I have another issue, I
use

System.IO.MemoryStream stream = new
System.IO.MemoryStream(binaryData);
RTFTextBlock.LoadFile(stream, RichTextBoxStreamType.RichText);

Now here if stream is not with rtf codes and is only plain text I get
an error that Invalid file format because I am using
RichTextBoxStreamType.RichText, can you tell me how can I incorporate
such that I can show both palin text and rtf in richtextbox.

Thanks
Nitin80r
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top