468,530 Members | 1,590 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,530 developers. It's quick & easy.

listview problem - simple problem

I have the following code in a listview control's
initList function (called from form_load event). i can't
understand why the listview box still appears blank with
no columns or listview items.

all help is appreciated.

public void initList()
{
listView1.Enabled = true;
listView1.View = View.Details;
listView1.CheckBoxes = true;
listView1.FullRowSelect = true;

ColumnHeader Col1 = new
ColumnHeader();
Col1.Text = "TestColA";
Col1.Width = 1000;

ColumnHeader Col2 = new
ColumnHeader();
Col2.Text = "TestColB";
Col2.Width = 1000;

ListViewItem lvwItem = new
ListViewItem();
listView1.Sorting =
SortOrder.Ascending;

// adding heading columns
listView1.Columns.Clear();
listView1.Columns.Add(Col1);
listView1.Columns.Add(Col2);

lvwItem.Text = "ABC";
listView1.Items.Add(lvwItem);
listView1.Items[0].SubItems.Add
("Test1");

lvwItem = new ListViewItem();
lvwItem.Text = "DEF";
listView1.Items.Add(lvwItem);
listView1.Items[0].SubItems.Add
("Test2");
}
Nov 15 '05 #1
1 1588
Hello newbie001,
I tried your code and it works. Please confirm if you are still having
problem with your code.

Thanks,
Mittal
--------------------
Content-Class: urn:content-classes:message
From: "newbie001" <ra****@eminem.com>
Sender: "newbie001" <ra****@eminem.com>
Subject: listview problem - simple problem
Date: Tue, 30 Sep 2003 08:50:18 -0700
Lines: 45
Message-ID: <1e****************************@phx.gbl>
MIME-Version: 1.0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
X-Newsreader: Microsoft CDO for Windows 2000
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
Thread-Index: AcOHaovrCWsdGqOST9+QA1wYI6K5Zg==
Newsgroups: microsoft.public.dotnet.languages.csharp
Path: cpmsftngxa06.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.csharp:188230
NNTP-Posting-Host: TK2MSFTNGXA12 10.40.1.164
X-Tomcat-NG: microsoft.public.dotnet.languages.csharp

I have the following code in a listview control's
initList function (called from form_load event). i can't
understand why the listview box still appears blank with
no columns or listview items.

all help is appreciated.

public void initList()
{
listView1.Enabled = true;
listView1.View = View.Details;
listView1.CheckBoxes = true;
listView1.FullRowSelect = true;

ColumnHeader Col1 = new
ColumnHeader();
Col1.Text = "TestColA";
Col1.Width = 1000;

ColumnHeader Col2 = new
ColumnHeader();
Col2.Text = "TestColB";
Col2.Width = 1000;

ListViewItem lvwItem = new
ListViewItem();
listView1.Sorting =
SortOrder.Ascending;

// adding heading columns
listView1.Columns.Clear();
listView1.Columns.Add(Col1);
listView1.Columns.Add(Col2);

lvwItem.Text = "ABC";
listView1.Items.Add(lvwItem);
listView1.Items[0].SubItems.Add
("Test1");

lvwItem = new ListViewItem();
lvwItem.Text = "DEF";
listView1.Items.Add(lvwItem);
listView1.Items[0].SubItems.Add
("Test2");
}


--
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm

Nov 15 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by David Miller | last post: by
1 post views Thread by J_Max | last post: by
reply views Thread by Sérgio Almeida | last post: by
1 post views Thread by cider123 | last post: by
3 posts views Thread by Michael.Suarez | last post: by
12 posts views Thread by garyusenet | last post: by
2 posts views Thread by =?Utf-8?B?UGhpbGlw?= | last post: by
reply views Thread by NPC403 | last post: by
1 post views Thread by fmendoza | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.