473,224 Members | 1,456 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,224 software developers and data experts.

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 1801
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: David Miller | last post by:
Hello, I posted this to DotNet.Framework.Controls a week ago or so and got no response, so now I will repost it here to see if anyone here knows anything about it... I have an application...
15
by: Wiktor Zychla | last post by:
today we've found a critical issue regarding the ListView from Windows.Forms. it was confirmed on several machines with Win2K and XP. here's the problem: create a ListView with about 50000 rows....
6
by: VM | last post by:
How can I fill up a listview with text file contents? My listview has two columns and the first column fills up with a while loop: while (myString != null) { myString = sr.Readline();...
1
by: J_Max | last post by:
Hello, This might be a really easy question, but... I am developing a simple Smart Device application that uses a listview. I have a function that adds a item to the listview - code is below. I...
0
by: Sérgio Almeida | last post by:
Greetings I have a problem using listview control. Well, I belive that this is not realy a problem, but it's consuming me precious time. Here is the scenario (an example of my problem). I...
1
by: cider123 | last post by:
I've tried working with the SelectedIndices and Items.Selected attributes to get the problem to go away, but not having any luck. Questions I have are: 1) How do you move (using code) the...
3
by: Michael.Suarez | last post by:
Is it me, or does it seem like they put no effort into creating the listview control in .Net. listview. A few gripes I have with .Net listview that aren't present in vb6: -Inability to set...
12
by: garyusenet | last post by:
I have had no replies to my previous post so perhaps I didn't write it good enough. Please excuse new thread but i wanted to break from the last thread hopefully this thread will be better. ...
2
by: =?Utf-8?B?UGhpbGlw?= | last post by:
I am attempting to insert a simple record with LinqDataSource from a ListView, however I always get a message saying "....LinqDataSource 'dataSource' has no values to insert. Check that the...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.