473,586 Members | 2,633 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ListView

Liz
How do I add columns ACROSS and lines down from an array
to a ListView.

ListView1.Updat e();
ListView1.Items .Clear();
ListView1.Items .Add(aClients[1].Surname);
ListView1.Items .Add(aClients[1].Forename);

**starts new line
Nov 15 '05 #1
4 5498
On Thu, 30 Oct 2003 04:19:57 -0800, Liz <ec******@cornw all.gov.uk> wrote:
How do I add columns ACROSS and lines down from an array
to a ListView.

ListView1.Updat e();
ListView1.Items .Clear();
ListView1.Items .Add(aClients[1].Surname);
ListView1.Items .Add(aClients[1].Forename);

**starts new line


Well, ListView1.Colum ns.Add whatever columns needed, then
something like this
foreach(row in array)
{
ListViewItem lItem = ListView1.Items .Add(row[0]);
for(int x = 1; x < rowcolumns)
{
lItem.SubItems. Add(row[x]);
}
}

or in this specific case

ListView1.Colum ns.Add(Surname) ;
ListView1.Colum ns.Add(Forename );

for(int x = 0; x < aClients.Count; x++)
{
ListViewItem lItem = ListView1.Items .Add(aClients[x].Surname);
lItem.SubItems. Add(aClients[x].Forename);
}

--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
Nov 15 '05 #2
Liz
Ah - subItems - thanks very much.

Now I'm having difficulty picking up which item was
selected. The following always gives me 17????

private void ListView1_Doubl eClick(object sender,
System.EventArg s e)
{
label10.Text = ListView1.TabIn dex.ToString();
}

-----Original Message-----
On Thu, 30 Oct 2003 04:19:57 -0800, Liz <ec******@cornw all.gov.uk> wrote:
How do I add columns ACROSS and lines down from an array to a ListView.

ListView1.Updat e();
ListView1.Items .Clear();
ListView1.Items .Add(aClients[1].Surname);
ListView1.Items .Add(aClients[1].Forename);

**starts new line
Well, ListView1.Colum ns.Add whatever columns needed, then
something like this
foreach(row in array)
{
ListViewItem lItem = ListView1.Items .Add(row[0]);
for(int x = 1; x < rowcolumns)
{
lItem.SubItems. Add(row[x]);
}
}

or in this specific case

ListView1.Colu mns.Add(Surname );
ListView1.Colu mns.Add(Forenam e);

for(int x = 0; x < aClients.Count; x++)
{
ListViewItem lItem = ListView1.Items .Add(aClients

[x].Surname); lItem.SubItems. Add(aClients[x].Forename);
}

--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/.

Nov 15 '05 #3
I would use
ListViewItem lItem = ListView1.Selec tedItems[0];
label0.Text = lItem.SubItems[0] + ", " + lItem.SubItems[1];

this should set label0 to "surname, forename";

--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
Nov 15 '05 #4
Liz
Thanks for your help.
-----Original Message-----
I would use
ListViewItem lItem = ListView1.Selec tedItems[0];
label0.Text = lItem.SubItems[0] + ", " + lItem.SubItems [1];
this should set label0 to "surname, forename";

--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/.

Nov 15 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
2618
by: Anushya | last post by:
Hi I am using Listview and inherited listview control overriding WndProc & PreProcessMessage in ListView. I need this to customize listview to display only the page the user scrolls to. Since i am populating listview with more than 200,000 items. It is too slow and tried virtual listview. But that doesnot allow me to add images in the...
0
489
by: Anushya | last post by:
Hi I am using Listview and inherited listview control overriding WndProc & PreProcessMessage in ListView. I need this to customize listview to display only the page the user scrolls to. Since i am populating listview with more than 200,000 items. It is too slow and tried virtual listview. But that doesnot allow me to add images in the...
0
2217
by: keith | last post by:
In a ListView control (two columns), I added a few ListView items. ListView listview=new ListView(); listview.Parent=this; listview.View=View.Details; listview.Columns.Add ("Col1",200,HorizontalAlignment.Left); listview.Columns.Add ("Col2",800,HorizontalAlignment.Left);
7
6428
by: Dave Y | last post by:
I am a newbie to C# and am having trouble trying to override a ListView property method. I have created a new class derived from the Forms.Listview and I cannot figure out the syntax to override ListView.Items.Add(), . I see that it is a virtual method so it should be easy to do. If anyone can help I would appreciate it greatly. I can do what...
7
14971
by: BobAchgill | last post by:
I am trying to decide which of these controls to use to implement letting my user select a full row from MyList. The MyList has several columns which would be nice to sort by at run time. The MyList data is resident in a dataset table. I'm stuck and can't choose either because. If I choose ListView as my control I don't understand how...
5
25942
by: John Devlon | last post by:
Hi, Does anyone know how to get a value of a second column of a selected item in Listview. I've create a listview and added this code Listview.Items.Clear() Listview.Columns.Clear() Listview.View = View.Details
0
1883
by: Peter | last post by:
Hi, I have a problem with Listview using checkboxes. If i check items by code BEFORE the form is shown the Listview.Items are confused during the ItemChecked Event !!! After showing the form every thing works fine: checking items by code as well as checking with mouse: Using the CheckdItems Property is confused too.
2
6818
by: Peter | last post by:
Hi, I have a problem with Listview using checkboxes. If i check items by code BEFORE the form is shown the Listview.Items are confused during the ItemChecked Event !!! After showing the form every thing works fine: checking items by code
4
4495
by: Brian Gaze | last post by:
I have created a ListView control and have bound this to a datasource. Within the ItemTemplate of the ListView I have added another ListViewControl which is databound in the code behind. The idea is that when clicking on the "Show details" button the ListView for the appropriate row binds in the codebehind and displays the detail data for the...
1
8341
by: =?Utf-8?B?UmF5IE1pdGNoZWxs?= | last post by:
Hello, In my application I need to periodically remove all current items from a ListView and add a new set into it. The following abbreviated code contains the basic idea: private void FillListViewFromFile(string path) {
0
7912
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8202
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. ...
1
7959
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...
0
6614
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...
1
5710
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...
0
5390
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3837
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...
0
3865
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1180
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...

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.