I have array of byte in C# and I want to represent array component as listview
.
I wrote this code but not display anything.
What is the error I am having which makes viewlist
not to show anything?
private void loadToolStripMenuItem_Click(object sender, EventArgs e)
{
byte[] bmp = File.ReadAllBytes(str);
ListView listView1 = new ListView();
listView1.View = View.Details;
listView1.FullRowSelect = true;
listView1.GridLines = true;
listView1.Columns.Add("Header Information",20);
listView1.Columns.Add("Description",20);
char x = (char)bmp[0];
char y = (char)bmp[1];
string st = null;
st += st + x + y;
listView1.Items.Add(st, 0);
listView1.Items.Add("signature", 1);
num = Convert.ToInt32(bmp[2]);
str = num.ToString();
listView1.Items.Add(str, 0);
listView1.Items.Add(" bytes size of BMP in Bytes", 1);
num = Convert.ToInt32(bmp[10]);
str = num.ToString();
listView1.Items.Add(str, 0);
listView1.Items.Add(" bytes offset to start of image data", 1);
}
You need to add this control to your form or panel like below
Controls.Add(listView1);
or
YourPanelName.Controls.Add(listView1);
if you have already added listview by designer ( e.g. named as ListView1
)
then you don't need to create new list view, you can directly add items
//ListView listView1 = new ListView();
listView1.View = View.Details;
listView1.FullRowSelect = true;
listView1.GridLines = true
listView1.Columns.Add("Header Information",20);
listView1.Columns.Add("Description",20);
listView1.Items.Add(new ListViewItem(new string[] {"Information", "Description"}));