I'm creating a flat file reader (simple hex editor if you will) in c# using RichTextBoxes
.
One RTB shows the hex values and another shows the ASCII values.
My plan is to show one 'record' per line. So, if there are 10 records I want to look at with a length of 1000, there will be 10 lines of 1000 characters per row in the ASCII and the hex side will have a length of 3000.
I dynamically set the rtb.RightMargin
property
to the length of one record.
The problem I'm running into is when the records are incredibly long, over 3500 chars for the ascii side making the hex side very large, I find that the text starts to disappear in the middle and end of the records when the right margin becomes too large. So for example:
hexRtb.RightMargin=7500//This is because it's triple the size of the ascii text.
In the hex
rtb
, it'll show the first parts of the text until I start scrolling towards the middle where all text stops showing completely. If I manage to click on these empty parts of the record, text will show up, but then disappear again after scrolling away.
I cannot figure out what's going on. This only seems to happen when the RightMargin is set to an incredibly large number. Smaller numbers, all text will shows without a problem. I have a horizontal scroll bar. They're all printable characters, so they're not carriage returns, nulls or anything. What's happening, from what I can tell, is that the pixels of the characters aren't there. Meaning, it'll show half of a 2 but not the other half. Then the rest of the line will be blank as well. I'll click on the half shown number and more of the line will reappear. It's the pixels that aren't showing from what I can see.
Anyone ever encountered something like this?
Here's a code sample if it helps.
int asciiRecordLength = mHexReader.RecordSize;int hexRecordLength = mHexReader.RecordSize*HexByte;//This is to convert the ascii record length to a hex record length asciiTextBox.RightMargin=TextRenderer.MeasureText(mHexReader.GetAsciiValues().Substring(0, asciiRecordLength), asciiTextBox.Font).Width; hexTextBox.RightMargin=TextRenderer.MeasureText(mHexReader.GetHexValues().Substring(0, hexRecordLength), hexTextBox.Font).Width;//Populate text boxes hexTextBox.Text+= mHexReader.GetHexValues();//This gets all of the records to be read asciiTextBox.Text+= mHexReader.GetAsciiValues();