473,320 Members | 1,859 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,320 software developers and data experts.

ListView

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

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

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

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

**starts new line


Well, ListView1.Columns.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.Columns.Add(Surname);
ListView1.Columns.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_DoubleClick(object sender,
System.EventArgs e)
{
label10.Text = ListView1.TabIndex.ToString();
}

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

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

**starts new line
Well, ListView1.Columns.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.Columns.Add(Surname);
ListView1.Columns.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 #3
I would use
ListViewItem lItem = ListView1.SelectedItems[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.SelectedItems[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
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...
0
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...
0
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...
7
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...
7
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...
5
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()...
0
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...
2
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...
4
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...
1
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...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.