|
|
|
The .NET framework includes a ByteViewer control, that you can use on your own forms to display data stored in a Byte array or in a file. The ByteViewer control can't be added to the control Toolbox, though, so you must instantiate it through code only. |
Click here to copy the following block |
Dim WithEvents bv As New ByteViewer()
Private Sub Form1_Load(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles MyBase.Load bv.Size = New Size(10, 100) bv.ForeColor = Color.Blue bv.BackColor = Color.LightGray bv.Visible = True Me.Controls.Add(bv)
bv.SetFile("c:\autoexec.bat") bv.SetDisplayMode(DisplayMode.Ansi) End Sub |
The SetDisplayMode method can take one of the following values: Ansi, Unicode, Hexdump, and Auto. In auto mode the control attempts to determine the display mode automatically. The DisplayMode.Hexdump value is very useful, in that the control displays both hex values and text. This is especially useful when used with the SetBytes method, that takes a Byte array as an argument: |
Click here to copy the following block | Dim sr As New System.IO.FileStream("c:\binary.dat", IO.FileMode.Open) Dim bytes(sr.Length - 1) As Byte sr.Read(bytes, 0, sr.Length) sr.Close()
bv.SetBytes(bytes) |
Notice that the ByteViewer class inherits from Control and therefore it exposes all the usual properties, methods, and events. However, a few properties don't work as usual. For example, the Width property is ignored and the control is always 633 pixels wide.
|
|
|
|
Submitted By :
Nayan Patel
(Member Since : 5/26/2004 12:23:06 PM)
|
|
|
Job Description :
He is the moderator of this site and currently working as an independent consultant. He works with VB.net/ASP.net, SQL Server and other MS technologies. He is MCSD.net, MCDBA and MCSE. In his free time he likes to watch funny movies and doing oil painting. |
View all (893) submissions by this author
(Birth Date : 7/14/1981 ) |
|
|