472,986 Members | 2,795 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Problem Creating ListView Items - updated

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.

This is the product of many different answers to different questions in
these forums. I dont really understand arraylists but the code is
working now except for the creation of the listview items. I can't seem
to create them. TIA. Gary.

using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using SHDocVw;

namespace InternetExplorerInterface
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{
ArrayList ar = new ArrayList();
foreach (InternetExplorer ie in new ShellWindows())
{
Int32 iLocation = ie.FullName.IndexOf("iexplore");
if (iLocation >= 0) ar.Add(ie);

}

foreach (InternetExplorer ie in ar)
{
int i = 0;
ListViewItem ("item" + i) = new
ListViewItem(ie.LocationURL, 0);
i++;
}

}

}
}

Nov 29 '06 #1
12 3336
When populating a ListView collection at runtime I often use code
similar to this:

ArrayList results = new ArrayList();

results.Add(new Person("1", "John", "Smith", 29,
"Madrid"));
results.Add(new Person("2", "John", "Smith", 29,
"Madrid"));
results.Add(new Person("3", "John", "Smith", 29,
"Madrid"));
results.Add(new Person("4", "John", "Smith", 29,
"Madrid"));
results.Add(new Person("5", "John", "Smith", 29,
"Madrid"));
results.Add(new Person("6", "John", "Smith", 29,
"Madrid"));
foreach(Person person in results)
{
ListViewItem item = new ListViewItem(person.ID);
item.SubItems.Add(person.FirstName);
item.SubItems.Add(person.LastName);
item.SubItems.Add(person.Age.ToString());
item.SubItems.Add(person.BirthPlace);

this.listView1.Items.Add(item);
}

Not sure if it helps...

Cheers
Robb

ga********@myway.com wrote:
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.

This is the product of many different answers to different questions in
these forums. I dont really understand arraylists but the code is
working now except for the creation of the listview items. I can't seem
to create them. TIA. Gary.

using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using SHDocVw;

namespace InternetExplorerInterface
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{
ArrayList ar = new ArrayList();
foreach (InternetExplorer ie in new ShellWindows())
{
Int32 iLocation = ie.FullName.IndexOf("iexplore");
if (iLocation >= 0) ar.Add(ie);

}

foreach (InternetExplorer ie in ar)
{
int i = 0;
ListViewItem ("item" + i) = new
ListViewItem(ie.LocationURL, 0);
i++;
}

}

}
}
Nov 29 '06 #2
Give people a chance Gary! Your earlier posts on this subject were only made
less than 4 hours before this one. People might be having a meal, watching a
movie, or (horrors of horrors) getting some sleep!

Seeing as you have provided nowhere enough information we have to play 20
questions.

What is 'InternetExplorer'? One can assume it's a class of some description
but what properties does it have that you wish to see in the ListView?

We can see that you are attempting to create a ListViewItem but what do you
want to do with it once you have created it? E.g. There is no point in
creating a swag of ListViewItems that go out of scope immediately.

You need to decide what 'columns' you want to see in the ListView and then
decide which property of 'InternetExplorer' provides the piece of
information for each column. Then and only then can you create the
ListViewItem which, of course you need to add to the ListView.
<ga********@myway.comwrote in message
news:11**********************@80g2000cwy.googlegro ups.com...
>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.

This is the product of many different answers to different questions in
these forums. I dont really understand arraylists but the code is
working now except for the creation of the listview items. I can't seem
to create them. TIA. Gary.

using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using SHDocVw;

namespace InternetExplorerInterface
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{
ArrayList ar = new ArrayList();
foreach (InternetExplorer ie in new ShellWindows())
{
Int32 iLocation = ie.FullName.IndexOf("iexplore");
if (iLocation >= 0) ar.Add(ie);

}

foreach (InternetExplorer ie in ar)
{
int i = 0;
ListViewItem ("item" + i) = new
ListViewItem(ie.LocationURL, 0);
i++;
}

}

}
}

Nov 29 '06 #3
Hi sorry for if my post was bad.

What I am doing is this. I am using SHDocVw to give me access to
Internet Explorer windows that are open on my computer. I don't
understand why SHDocVw allows me to do this, but following examples on
the internet I have managed to get it working.

This is the heart of the programme I have written so far: -

ArrayList ar = new ArrayList();
foreach (InternetExplorer ie in new ShellWindows())
{
Int32 iLocation = ie.FullName.IndexOf("iexplore");
if (iLocation >= 0) ar.Add(ie);

}

When a new ShellWindows() is created it somehow (i don't understand
how) builds a list of open windows on the computer. I then use a
foreach to isolate those windows that are of type InternetExplorer
(again i don't understand the type, but have managed to get it to
work).

However not all windows of type InternetExplorer are actually internet
explorer windows, for instance the 'search' window in XP is of type
internet explorer. However by using the property: -

ie.FullName.IndexOf

I can isolate only the 'internet explorer' windows. The foreach loop
builds an array list of these internet explorer windows. I don't
understand arraylists (i have just about got to grips with one
dimensional arrays!)

So I have an arraylist with all my open internet explorer windows.

Now I hope I have explained better the background. To the heart of the
problem I hope you can all help with. I now want to display a list of
all open Internet Explorer windows to the user. The user then decides
which window they would like to work with (so i just want a variable
returned which uniquely references a particular window, so I know which
one the user wants to work with.) My first thoughts are that the
Titlebar text, and the URL of the window in question would suffice to
distinguish between open windows. And so I need a way of presenting
these two pieces of information to the user for every open window, and
then allowing the user to select one of these windows to work with.
Following Stephany's very kind and helpful post in windowsforms, it
would seem that the listview control is the best way of doing this.

So my columns would look something like this.

Window Number | Titlebar Text | URL address from address bar
----------------------------------------------------------------------------------------------

Titlebar Text is accessed from the property: ie.LocationName
Current URL is accessed from the property: ie.LocationURL

I have two problems. The first problem I have is creating the listview
control. I have found some code that shows me how to create a listview
control in code, but it dimensions it. I am thinking I would need it to
be automatically dimensioned to allow for varying numbers of windows
that it needs to display. The second and more daunting problem I have
is i do not know how to populate the Listview control with the two
pieces of information (LocationName, and Location URL) from my
arraylist.

As my listview code doesn't work i've deleted it from my programme. So
my programme as posted below is functioning in itself, and is quite
succinct. I hope someone can spare the time to help me with this.

I hope I have provided enough information now, If anyone needs any more
information, please just ask.

using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using SHDocVw;

namespace InternetExplorerInterface
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{
ArrayList ar = new ArrayList();
foreach (InternetExplorer ie in new ShellWindows())
{
Int32 iLocation = ie.FullName.IndexOf("iexplore");
if (iLocation >= 0) ar.Add(ie);
}
}
}
}

Nov 30 '06 #4
Gary!

The ListView is a Windows control that you drag from the toolboz and drop it
on your form. Once you have done that you can size it to however you want
it.

Once you have done that you nedd to set it's View property to "Details". Now
you can create 3 columns (or more correctly ColumnHeaders) in you ListView.

If you haven't got a window number in your InternetExplorer object then I
would suggest that you don't even attempt to try and create one, because you
don't really need one anyway.

To add the information at runtime it is then matter of adding ListViewItems.
Each ListViewItem will equate to a row in the ListView which in turn will
equate to a single element of your Arraylist of InternetExplorer objects.

foreach (InternetExplorer ie in ar)
{
listView1.Items.Add(New ListViewItem(new string[] {ie.LocationName,
ie.LocationURL}))
}

I strongly recommend that you read the documentation on the ListView class
and control and the ListViewItem class. All you need to know is demonstrated
in the included examples.

<ga********@myway.comwrote in message
news:11**********************@16g2000cwy.googlegro ups.com...
Hi sorry for if my post was bad.

What I am doing is this. I am using SHDocVw to give me access to
Internet Explorer windows that are open on my computer. I don't
understand why SHDocVw allows me to do this, but following examples on
the internet I have managed to get it working.

This is the heart of the programme I have written so far: -

ArrayList ar = new ArrayList();
foreach (InternetExplorer ie in new ShellWindows())
{
Int32 iLocation = ie.FullName.IndexOf("iexplore");
if (iLocation >= 0) ar.Add(ie);

}

When a new ShellWindows() is created it somehow (i don't understand
how) builds a list of open windows on the computer. I then use a
foreach to isolate those windows that are of type InternetExplorer
(again i don't understand the type, but have managed to get it to
work).

However not all windows of type InternetExplorer are actually internet
explorer windows, for instance the 'search' window in XP is of type
internet explorer. However by using the property: -

ie.FullName.IndexOf

I can isolate only the 'internet explorer' windows. The foreach loop
builds an array list of these internet explorer windows. I don't
understand arraylists (i have just about got to grips with one
dimensional arrays!)

So I have an arraylist with all my open internet explorer windows.

Now I hope I have explained better the background. To the heart of the
problem I hope you can all help with. I now want to display a list of
all open Internet Explorer windows to the user. The user then decides
which window they would like to work with (so i just want a variable
returned which uniquely references a particular window, so I know which
one the user wants to work with.) My first thoughts are that the
Titlebar text, and the URL of the window in question would suffice to
distinguish between open windows. And so I need a way of presenting
these two pieces of information to the user for every open window, and
then allowing the user to select one of these windows to work with.
Following Stephany's very kind and helpful post in windowsforms, it
would seem that the listview control is the best way of doing this.

So my columns would look something like this.

Window Number | Titlebar Text | URL address from address bar
----------------------------------------------------------------------------------------------

Titlebar Text is accessed from the property: ie.LocationName
Current URL is accessed from the property: ie.LocationURL

I have two problems. The first problem I have is creating the listview
control. I have found some code that shows me how to create a listview
control in code, but it dimensions it. I am thinking I would need it to
be automatically dimensioned to allow for varying numbers of windows
that it needs to display. The second and more daunting problem I have
is i do not know how to populate the Listview control with the two
pieces of information (LocationName, and Location URL) from my
arraylist.

As my listview code doesn't work i've deleted it from my programme. So
my programme as posted below is functioning in itself, and is quite
succinct. I hope someone can spare the time to help me with this.

I hope I have provided enough information now, If anyone needs any more
information, please just ask.

using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using SHDocVw;

namespace InternetExplorerInterface
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{
ArrayList ar = new ArrayList();
foreach (InternetExplorer ie in new ShellWindows())
{
Int32 iLocation = ie.FullName.IndexOf("iexplore");
if (iLocation >= 0) ar.Add(ie);
}
}
}
}

Nov 30 '06 #5
Hi Stephany I tried that but it's not working.

It says ' missing ) '

I have:

foreach (InternetExplorer ie in ar)
{

listView1.Items.Add(New ListViewItem(new string[]
{ie.LocationName, ie.LocationURL})) ;
}
Gary!

The ListView is a Windows control that you drag from the toolboz and drop it
on your form. Once you have done that you can size it to however you want
it.

Once you have done that you nedd to set it's View property to "Details". Now
you can create 3 columns (or more correctly ColumnHeaders) in you ListView.

If you haven't got a window number in your InternetExplorer object then I
would suggest that you don't even attempt to try and create one, because you
don't really need one anyway.

To add the information at runtime it is then matter of adding ListViewItems.
Each ListViewItem will equate to a row in the ListView which in turn will
equate to a single element of your Arraylist of InternetExplorer objects.

foreach (InternetExplorer ie in ar)
{
listView1.Items.Add(New ListViewItem(new string[] {ie.LocationName,
ie.LocationURL}))
}

I strongly recommend that you read the documentation on the ListView class
and control and the ListViewItem class. All you need to know is demonstrated
in the included examples.

<ga********@myway.comwrote in message
news:11**********************@16g2000cwy.googlegro ups.com...
Hi sorry for if my post was bad.

What I am doing is this. I am using SHDocVw to give me access to
Internet Explorer windows that are open on my computer. I don't
understand why SHDocVw allows me to do this, but following examples on
the internet I have managed to get it working.

This is the heart of the programme I have written so far: -

ArrayList ar = new ArrayList();
foreach (InternetExplorer ie in new ShellWindows())
{
Int32 iLocation = ie.FullName.IndexOf("iexplore");
if (iLocation >= 0) ar.Add(ie);

}

When a new ShellWindows() is created it somehow (i don't understand
how) builds a list of open windows on the computer. I then use a
foreach to isolate those windows that are of type InternetExplorer
(again i don't understand the type, but have managed to get it to
work).

However not all windows of type InternetExplorer are actually internet
explorer windows, for instance the 'search' window in XP is of type
internet explorer. However by using the property: -

ie.FullName.IndexOf

I can isolate only the 'internet explorer' windows. The foreach loop
builds an array list of these internet explorer windows. I don't
understand arraylists (i have just about got to grips with one
dimensional arrays!)

So I have an arraylist with all my open internet explorer windows.

Now I hope I have explained better the background. To the heart of the
problem I hope you can all help with. I now want to display a list of
all open Internet Explorer windows to the user. The user then decides
which window they would like to work with (so i just want a variable
returned which uniquely references a particular window, so I know which
one the user wants to work with.) My first thoughts are that the
Titlebar text, and the URL of the window in question would suffice to
distinguish between open windows. And so I need a way of presenting
these two pieces of information to the user for every open window, and
then allowing the user to select one of these windows to work with.
Following Stephany's very kind and helpful post in windowsforms, it
would seem that the listview control is the best way of doing this.

So my columns would look something like this.

Window Number | Titlebar Text | URL address from address bar
----------------------------------------------------------------------------------------------

Titlebar Text is accessed from the property: ie.LocationName
Current URL is accessed from the property: ie.LocationURL

I have two problems. The first problem I have is creating the listview
control. I have found some code that shows me how to create a listview
control in code, but it dimensions it. I am thinking I would need it to
be automatically dimensioned to allow for varying numbers of windows
that it needs to display. The second and more daunting problem I have
is i do not know how to populate the Listview control with the two
pieces of information (LocationName, and Location URL) from my
arraylist.

As my listview code doesn't work i've deleted it from my programme. So
my programme as posted below is functioning in itself, and is quite
succinct. I hope someone can spare the time to help me with this.

I hope I have provided enough information now, If anyone needs any more
information, please just ask.

using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using SHDocVw;

namespace InternetExplorerInterface
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{
ArrayList ar = new ArrayList();
foreach (InternetExplorer ie in new ShellWindows())
{
Int32 iLocation = ie.FullName.IndexOf("iexplore");
if (iLocation >= 0) ar.Add(ie);
}
}
}
}
Nov 30 '06 #6
1. Make sure that all the the ( and ) match.

2. Press F1 and check the actual syntax for the ListView.Items.Add method.

3. Learn some basic programming skills before you start trying to do
something as complex as you are attempting.
<ga********@myway.comwrote in message
news:11*********************@j44g2000cwa.googlegro ups.com...
Hi Stephany I tried that but it's not working.

It says ' missing ) '

I have:

foreach (InternetExplorer ie in ar)
{

listView1.Items.Add(New ListViewItem(new string[]
{ie.LocationName, ie.LocationURL})) ;
}
>Gary!

The ListView is a Windows control that you drag from the toolboz and drop
it
on your form. Once you have done that you can size it to however you want
it.

Once you have done that you nedd to set it's View property to "Details".
Now
you can create 3 columns (or more correctly ColumnHeaders) in you
ListView.

If you haven't got a window number in your InternetExplorer object then
I
would suggest that you don't even attempt to try and create one, because
you
don't really need one anyway.

To add the information at runtime it is then matter of adding
ListViewItems.
Each ListViewItem will equate to a row in the ListView which in turn will
equate to a single element of your Arraylist of InternetExplorer objects.

foreach (InternetExplorer ie in ar)
{
listView1.Items.Add(New ListViewItem(new string[] {ie.LocationName,
ie.LocationURL}))
}

I strongly recommend that you read the documentation on the ListView
class
and control and the ListViewItem class. All you need to know is
demonstrated
in the included examples.

<ga********@myway.comwrote in message
news:11**********************@16g2000cwy.googlegr oups.com...
Hi sorry for if my post was bad.

What I am doing is this. I am using SHDocVw to give me access to
Internet Explorer windows that are open on my computer. I don't
understand why SHDocVw allows me to do this, but following examples on
the internet I have managed to get it working.

This is the heart of the programme I have written so far: -

ArrayList ar = new ArrayList();
foreach (InternetExplorer ie in new ShellWindows())
{
Int32 iLocation = ie.FullName.IndexOf("iexplore");
if (iLocation >= 0) ar.Add(ie);

}

When a new ShellWindows() is created it somehow (i don't understand
how) builds a list of open windows on the computer. I then use a
foreach to isolate those windows that are of type InternetExplorer
(again i don't understand the type, but have managed to get it to
work).

However not all windows of type InternetExplorer are actually internet
explorer windows, for instance the 'search' window in XP is of type
internet explorer. However by using the property: -

ie.FullName.IndexOf

I can isolate only the 'internet explorer' windows. The foreach loop
builds an array list of these internet explorer windows. I don't
understand arraylists (i have just about got to grips with one
dimensional arrays!)

So I have an arraylist with all my open internet explorer windows.

Now I hope I have explained better the background. To the heart of the
problem I hope you can all help with. I now want to display a list of
all open Internet Explorer windows to the user. The user then decides
which window they would like to work with (so i just want a variable
returned which uniquely references a particular window, so I know which
one the user wants to work with.) My first thoughts are that the
Titlebar text, and the URL of the window in question would suffice to
distinguish between open windows. And so I need a way of presenting
these two pieces of information to the user for every open window, and
then allowing the user to select one of these windows to work with.
Following Stephany's very kind and helpful post in windowsforms, it
would seem that the listview control is the best way of doing this.

So my columns would look something like this.

Window Number | Titlebar Text | URL address from address bar
----------------------------------------------------------------------------------------------

Titlebar Text is accessed from the property: ie.LocationName
Current URL is accessed from the property: ie.LocationURL

I have two problems. The first problem I have is creating the listview
control. I have found some code that shows me how to create a listview
control in code, but it dimensions it. I am thinking I would need it to
be automatically dimensioned to allow for varying numbers of windows
that it needs to display. The second and more daunting problem I have
is i do not know how to populate the Listview control with the two
pieces of information (LocationName, and Location URL) from my
arraylist.

As my listview code doesn't work i've deleted it from my programme. So
my programme as posted below is functioning in itself, and is quite
succinct. I hope someone can spare the time to help me with this.

I hope I have provided enough information now, If anyone needs any more
information, please just ask.

using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using SHDocVw;

namespace InternetExplorerInterface
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{
ArrayList ar = new ArrayList();
foreach (InternetExplorer ie in new ShellWindows())
{
Int32 iLocation = ie.FullName.IndexOf("iexplore");
if (iLocation >= 0) ar.Add(ie);
}
}
}
}

Nov 30 '06 #7
Stephanies code has proved of no use as it has generated compile time
errors.
So i'm still looking for a solution if someone would care to offer one!

TIA.

Gary.

Stephany Young wrote:
1. Make sure that all the the ( and ) match.

2. Press F1 and check the actual syntax for the ListView.Items.Add method.

3. Learn some basic programming skills before you start trying to do
something as complex as you are attempting.
<ga********@myway.comwrote in message
news:11*********************@j44g2000cwa.googlegro ups.com...
Hi Stephany I tried that but it's not working.

It says ' missing ) '

I have:

foreach (InternetExplorer ie in ar)
{

listView1.Items.Add(New ListViewItem(new string[]
{ie.LocationName, ie.LocationURL})) ;
}
Gary!

The ListView is a Windows control that you drag from the toolboz and drop
it
on your form. Once you have done that you can size it to however you want
it.

Once you have done that you nedd to set it's View property to "Details".
Now
you can create 3 columns (or more correctly ColumnHeaders) in you
ListView.

If you haven't got a window number in your InternetExplorer object then
I
would suggest that you don't even attempt to try and create one, because
you
don't really need one anyway.

To add the information at runtime it is then matter of adding
ListViewItems.
Each ListViewItem will equate to a row in the ListView which in turn will
equate to a single element of your Arraylist of InternetExplorer objects.

foreach (InternetExplorer ie in ar)
{
listView1.Items.Add(New ListViewItem(new string[] {ie.LocationName,
ie.LocationURL}))
}

I strongly recommend that you read the documentation on the ListView
class
and control and the ListViewItem class. All you need to know is
demonstrated
in the included examples.

<ga********@myway.comwrote in message
news:11**********************@16g2000cwy.googlegro ups.com...
Hi sorry for if my post was bad.

What I am doing is this. I am using SHDocVw to give me access to
Internet Explorer windows that are open on my computer. I don't
understand why SHDocVw allows me to do this, but following examples on
the internet I have managed to get it working.

This is the heart of the programme I have written so far: -

ArrayList ar = new ArrayList();
foreach (InternetExplorer ie in new ShellWindows())
{
Int32 iLocation = ie.FullName.IndexOf("iexplore");
if (iLocation >= 0) ar.Add(ie);

}

When a new ShellWindows() is created it somehow (i don't understand
how) builds a list of open windows on the computer. I then use a
foreach to isolate those windows that are of type InternetExplorer
(again i don't understand the type, but have managed to get it to
work).

However not all windows of type InternetExplorer are actually internet
explorer windows, for instance the 'search' window in XP is of type
internet explorer. However by using the property: -

ie.FullName.IndexOf

I can isolate only the 'internet explorer' windows. The foreach loop
builds an array list of these internet explorer windows. I don't
understand arraylists (i have just about got to grips with one
dimensional arrays!)

So I have an arraylist with all my open internet explorer windows.

Now I hope I have explained better the background. To the heart of the
problem I hope you can all help with. I now want to display a list of
all open Internet Explorer windows to the user. The user then decides
which window they would like to work with (so i just want a variable
returned which uniquely references a particular window, so I know which
one the user wants to work with.) My first thoughts are that the
Titlebar text, and the URL of the window in question would suffice to
distinguish between open windows. And so I need a way of presenting
these two pieces of information to the user for every open window, and
then allowing the user to select one of these windows to work with.
Following Stephany's very kind and helpful post in windowsforms, it
would seem that the listview control is the best way of doing this.

So my columns would look something like this.

Window Number | Titlebar Text | URL address from address bar
----------------------------------------------------------------------------------------------

Titlebar Text is accessed from the property: ie.LocationName
Current URL is accessed from the property: ie.LocationURL

I have two problems. The first problem I have is creating the listview
control. I have found some code that shows me how to create a listview
control in code, but it dimensions it. I am thinking I would need it to
be automatically dimensioned to allow for varying numbers of windows
that it needs to display. The second and more daunting problem I have
is i do not know how to populate the Listview control with the two
pieces of information (LocationName, and Location URL) from my
arraylist.

As my listview code doesn't work i've deleted it from my programme. So
my programme as posted below is functioning in itself, and is quite
succinct. I hope someone can spare the time to help me with this.

I hope I have provided enough information now, If anyone needs any more
information, please just ask.

using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using SHDocVw;

namespace InternetExplorerInterface
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{
ArrayList ar = new ArrayList();
foreach (InternetExplorer ie in new ShellWindows())
{
Int32 iLocation = ie.FullName.IndexOf("iexplore");
if (iLocation >= 0) ar.Add(ie);
}
}
}
}
Nov 30 '06 #8
Stephanie's code is correct. What you need is to get yourself on a
beginners' training course.

This group is not staffed by people paid to help you learn (not unless
you've paid some dosh to Microsoft in which case MS staff will answer
your questions).
Most people on this group read it to learn or to find answers to
immediate questions - but not as beginners. I would guess that over 90%
of people posting anything here (questions included) are professional
programmers helping out their peers. However, this is not the correct
place for a beginner to learn how to program - and from your questions
your are very obviously a beginner.
In addition to that, you are rude. That's not a good formula to get
help.

My best advice to you is to get yourself on a course - there are many
about. Also get a book. There are many for C#. Your questions show that
you don't know enough to ask sensible questions about general things,
and when given specific answers you don't understand them.

I'm not trying to knock you, but programming - or at least producing
good code - is hard work. You must learn it properly.

Just as an exercise, take Stephanie's code and use F1 to look up the
constructor for ListViewItem and try to work out what her code is
doing.
Good luck!
ga********@myway.com wrote:
Stephanies code has proved of no use as it has generated compile time
errors.
So i'm still looking for a solution if someone would care to offer one!

TIA.

Gary.

Stephany Young wrote:
1. Make sure that all the the ( and ) match.

2. Press F1 and check the actual syntax for the ListView.Items.Add method.

3. Learn some basic programming skills before you start trying to do
something as complex as you are attempting.
<ga********@myway.comwrote in message
news:11*********************@j44g2000cwa.googlegro ups.com...
Hi Stephany I tried that but it's not working.
>
It says ' missing ) '
>
I have:
>
foreach (InternetExplorer ie in ar)
{
>
listView1.Items.Add(New ListViewItem(new string[]
{ie.LocationName, ie.LocationURL})) ;
}
>
>Gary!
>>
Nov 30 '06 #9
Stephanie's code is correct. What you need is to get yourself on a
beginners' training course.

This group is not staffed by people paid to help you learn (not unless
you've paid some dosh to Microsoft in which case MS staff will answer
your questions).
Most people on this group read it to learn or to find answers to
immediate questions - but not as beginners. I would guess that over 90%
of people posting anything here (questions included) are professional
programmers helping out their peers. However, this is not the correct
place for a beginner to learn how to program - and from your questions
your are very obviously a beginner.
In addition to that, you are rude. That's not a good formula to get
help.

My best advice to you is to get yourself on a course - there are many
about. Also get a book. There are many for C#. Your questions show that
you don't know enough to ask sensible questions about general things,
and when given specific answers you don't understand them.

I'm not trying to knock you, but programming - or at least producing
good code - is hard work. You must learn it properly.

Just as an exercise, take Stephanie's code and use F1 to look up the
constructor for ListViewItem and try to work out what her code is
doing.
Good luck!
ga********@myway.com wrote:
Stephanies code has proved of no use as it has generated compile time
errors.
So i'm still looking for a solution if someone would care to offer one!

TIA.

Gary.

Stephany Young wrote:
1. Make sure that all the the ( and ) match.

2. Press F1 and check the actual syntax for the ListView.Items.Add method.

3. Learn some basic programming skills before you start trying to do
something as complex as you are attempting.
<ga********@myway.comwrote in message
news:11*********************@j44g2000cwa.googlegro ups.com...
Hi Stephany I tried that but it's not working.
>
It says ' missing ) '
>
I have:
>
foreach (InternetExplorer ie in ar)
{
>
listView1.Items.Add(New ListViewItem(new string[]
{ie.LocationName, ie.LocationURL})) ;
}
>
>Gary!
>>
Nov 30 '06 #10
Life is too short to argue with you. The code is not correct. I have
been on a beginners training course. If you have no constructive input
to a thread do not participate.

Nov 30 '06 #11
And in case you was reading my abrupt reply to Stephany out of context
please see her less than useful comments in my previous thread.

http://groups.google.com/group/micro...d8dc60e64e0b1c

garyuse...@myway.com wrote:
Life is too short to argue with you. The code is not correct. I have
been on a beginners training course. If you have no constructive input
to a thread do not participate.
Nov 30 '06 #12
Thanks Mark, that's exactly what i was looking for!

Mark R. Dawson wrote:
Hi Gary,
you first need to have a ListView control placed somewhere on your form,
then you need to add ListViewItem s to the ListViews item collection. For
example if I have a ListView on my form called listView1:

for (int i = 0; i < 10; ++i)
{
this.listView1.Items.Add(new ListViewItem("Item:" + i));
}

This is a simple example since the ListView is quite configurable and can
show it's content in a varienty of ways.

HTH
Mark.
--
http://www.markdawson.org
"ga********@myway.com" wrote:
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.

This is the product of many different answers to different questions in
these forums. I dont really understand arraylists but the code is
working now except for the creation of the listview items. I can't seem
to create them. TIA. Gary.

using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using SHDocVw;

namespace InternetExplorerInterface
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{
ArrayList ar = new ArrayList();
foreach (InternetExplorer ie in new ShellWindows())
{
Int32 iLocation = ie.FullName.IndexOf("iexplore");
if (iLocation >= 0) ar.Add(ie);

}

foreach (InternetExplorer ie in ar)
{
int i = 0;
ListViewItem ("item" + i) = new
ListViewItem(ie.LocationURL, 0);
i++;
}

}

}
}
Dec 1 '06 #13

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

Similar topics

3
by: andrewcw | last post by:
I have a simple winform with the following code. But although I can read back the info, the display fails to provide the text or the cell background color changes. private void ListViewBroke()...
1
by: newbie001 | last post by:
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. ...
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...
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...
2
by: John Lee | last post by:
Hi, I have a windows application that uses the listview to display about 50 items in detailed view - 4 columns. The first column is static and other columns will be updated in 100-1000ms - it...
2
by: John Lee | last post by:
Thanks Jay for your response. I tried your code and it still flickering a lot. To demonstrate it, you can grab a listview, create 3 columns - name, value, timestamp, in form_load event to add 50...
2
by: farmer | last post by:
I need to populate a listbox of other listview with selected listview items.although the following code works perfecty I want to use an Array (for various reasons) for Each ListItem In...
1
by: Derck | last post by:
SORRY, for the crosspost, but I think I posted it in the wrong group! Hello all, I have a question.. I am tying to make a global listview class where other listviews in my application points...
7
by: =?Utf-8?B?YnJhaW5mdWVsbWVkaWE=?= | last post by:
Can anyone point me in the direction of creating a custom listview item? I guess the other question then - is this possible? I want to create a list of listview items comprised each comprised of...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
3
SueHopson
by: SueHopson | last post by:
Hi All, I'm trying to create a single code (run off a button that calls the Private Sub) for our parts list report that will allow the user to filter by either/both PartVendor and PartType. On...

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.