By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,846 Members | 1,211 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,846 IT Pros & Developers. It's quick & easy.

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

P: n/a
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);
}
Nov 15 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"nitin8or" <bh**********@yahoo.com> wrote in message
news:8e**************************@posting.google.c om...
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);
}

Nov 15 '05 #2

P: n/a
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
Nov 15 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.