0
Reply

Cannot display byte arrays in Rich Text Box Please help

nitin 0

nitin 0

Jan 8 2004 10:56 AM
2.1k
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); }