473,398 Members | 2,212 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,398 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 1826
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.