473,729 Members | 2,328 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Enabl ed = true;
listView1.View = View.Details;
listView1.Check Boxes = true;
listView1.FullR owSelect = 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.Sorti ng =
SortOrder.Ascen ding;

// adding heading columns
listView1.Colum ns.Clear();
listView1.Colum ns.Add(Col1);
listView1.Colum ns.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 1853
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: AcOHaovrCWsdGqO ST9+QA1wYI6K5Zg ==
Newsgroups: microsoft.publi c.dotnet.langua ges.csharp
Path: cpmsftngxa06.ph x.gbl
Xref: cpmsftngxa06.ph x.gbl microsoft.publi c.dotnet.langua ges.csharp:1882 30
NNTP-Posting-Host: TK2MSFTNGXA12 10.40.1.164
X-Tomcat-NG: microsoft.publi c.dotnet.langua ges.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.Enabl ed = true;
listView1.View = View.Details;
listView1.Check Boxes = true;
listView1.FullR owSelect = 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.Sorti ng =
SortOrder.Asce nding;

// adding heading columns
listView1.Colum ns.Clear();
listView1.Colum ns.Add(Col1);
listView1.Colum ns.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
4756
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 that displays items in a ListView control that is running on a Windows 98 SE machine. The machine is well within system specifications for the .Net Framework. It is a 600 MHz with 128 MB of RAM, and also has the Resource Meter application installed....
15
3891
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. now use task manager to see the GDI usage of the process. everything seems normal. now catch the ListView's scroller and start to move it downwards. you have to hold the constant speed so that the ListView is constantly repainted. look at the...
6
4655
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(); listView1.Items.Add (myString); } Is there a way I can fill up the second column this easily? Thw way I'm currently doing it is using the subitems property to add it. Unfortunately,
1
787
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 use the type listviewitem, selitem, on one form to modify the listviewitem, using a timer, every second, and use selitem1 to modify items, after they have ended the time on the timer form, from the form that the listview is located - this way I...
0
1423
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 have a SqlServer CE table named students that has 2 fields: students name and grade.
1
5049
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 focus Rectangle when your Selected Index changes ? 2) If there are no selected rows, can that focus rectangle be removed? 3) What other quirks exist in this simple example I might need to code for ?
3
2394
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 tooltiptext of subitems (without the use of a very inconveniant work around). -Inability to display images in subitems (without using the windows api
12
3412
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. Very simple. I would like to create listviewitem's for display in a listview control. The listview items need to contain properties from Internet Explorer windows i've managed to collect into an arraylist.
2
3360
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 'values' dictionary contains values...." I am using a ListView with a DataSourceID of a LinqDataSource. When a new row icon is clicked....the ListView properly enters into the InsertItemTemplate....however when the ImageButton with a CommandName of...
0
8763
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9427
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9202
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8151
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6722
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4528
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3238
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2683
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2165
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.