473,721 Members | 2,262 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Collecti ons;
using System.Collecti ons.Generic;
using System.Componen tModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows. Forms;
using SHDocVw;

namespace InternetExplore rInterface
{
public partial class Form1 : Form
{
public Form1()
{
InitializeCompo nent();
}

private void Form1_Load(obje ct sender, EventArgs e)
{
ArrayList ar = new ArrayList();
foreach (InternetExplor er ie in new ShellWindows())
{
Int32 iLocation = ie.FullName.Ind exOf("iexplore" );
if (iLocation >= 0) ar.Add(ie);

}

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

}

}
}

Nov 29 '06 #1
12 3411
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(pe rson.ID);
item.SubItems.A dd(person.First Name);
item.SubItems.A dd(person.LastN ame);
item.SubItems.A dd(person.Age.T oString());
item.SubItems.A dd(person.Birth Place);

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

Not sure if it helps...

Cheers
Robb

ga********@mywa y.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.Collecti ons;
using System.Collecti ons.Generic;
using System.Componen tModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows. Forms;
using SHDocVw;

namespace InternetExplore rInterface
{
public partial class Form1 : Form
{
public Form1()
{
InitializeCompo nent();
}

private void Form1_Load(obje ct sender, EventArgs e)
{
ArrayList ar = new ArrayList();
foreach (InternetExplor er ie in new ShellWindows())
{
Int32 iLocation = ie.FullName.Ind exOf("iexplore" );
if (iLocation >= 0) ar.Add(ie);

}

foreach (InternetExplor er 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 'InternetExplor er'? 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 'InternetExplor er' 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********@myw ay.comwrote in message
news:11******** **************@ 80g2000cwy.goog legroups.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.Collecti ons;
using System.Collecti ons.Generic;
using System.Componen tModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows. Forms;
using SHDocVw;

namespace InternetExplore rInterface
{
public partial class Form1 : Form
{
public Form1()
{
InitializeCompo nent();
}

private void Form1_Load(obje ct sender, EventArgs e)
{
ArrayList ar = new ArrayList();
foreach (InternetExplor er ie in new ShellWindows())
{
Int32 iLocation = ie.FullName.Ind exOf("iexplore" );
if (iLocation >= 0) ar.Add(ie);

}

foreach (InternetExplor er 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 (InternetExplor er ie in new ShellWindows())
{
Int32 iLocation = ie.FullName.Ind exOf("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 InternetExplore r
(again i don't understand the type, but have managed to get it to
work).

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

ie.FullName.Ind exOf

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.Collecti ons;
using System.Collecti ons.Generic;
using System.Componen tModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows. Forms;
using SHDocVw;

namespace InternetExplore rInterface
{
public partial class Form1 : Form
{
public Form1()
{
InitializeCompo nent();
}

private void Form1_Load(obje ct sender, EventArgs e)
{
ArrayList ar = new ArrayList();
foreach (InternetExplor er ie in new ShellWindows())
{
Int32 iLocation = ie.FullName.Ind exOf("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 InternetExplore r 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 InternetExplore r objects.

foreach (InternetExplor er ie in ar)
{
listView1.Items .Add(New ListViewItem(ne w string[] {ie.LocationNam e,
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********@myw ay.comwrote in message
news:11******** **************@ 16g2000cwy.goog legroups.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 (InternetExplor er ie in new ShellWindows())
{
Int32 iLocation = ie.FullName.Ind exOf("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 InternetExplore r
(again i don't understand the type, but have managed to get it to
work).

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

ie.FullName.Ind exOf

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.Collecti ons;
using System.Collecti ons.Generic;
using System.Componen tModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows. Forms;
using SHDocVw;

namespace InternetExplore rInterface
{
public partial class Form1 : Form
{
public Form1()
{
InitializeCompo nent();
}

private void Form1_Load(obje ct sender, EventArgs e)
{
ArrayList ar = new ArrayList();
foreach (InternetExplor er ie in new ShellWindows())
{
Int32 iLocation = ie.FullName.Ind exOf("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 (InternetExplor er ie in ar)
{

listView1.Items .Add(New ListViewItem(ne w string[]
{ie.LocationNam e, 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 InternetExplore r 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 InternetExplore r objects.

foreach (InternetExplor er ie in ar)
{
listView1.Items .Add(New ListViewItem(ne w string[] {ie.LocationNam e,
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********@myw ay.comwrote in message
news:11******** **************@ 16g2000cwy.goog legroups.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 (InternetExplor er ie in new ShellWindows())
{
Int32 iLocation = ie.FullName.Ind exOf("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 InternetExplore r
(again i don't understand the type, but have managed to get it to
work).

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

ie.FullName.Ind exOf

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.Collecti ons;
using System.Collecti ons.Generic;
using System.Componen tModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows. Forms;
using SHDocVw;

namespace InternetExplore rInterface
{
public partial class Form1 : Form
{
public Form1()
{
InitializeCompo nent();
}

private void Form1_Load(obje ct sender, EventArgs e)
{
ArrayList ar = new ArrayList();
foreach (InternetExplor er ie in new ShellWindows())
{
Int32 iLocation = ie.FullName.Ind exOf("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********@myw ay.comwrote in message
news:11******** *************@j 44g2000cwa.goog legroups.com...
Hi Stephany I tried that but it's not working.

It says ' missing ) '

I have:

foreach (InternetExplor er ie in ar)
{

listView1.Items .Add(New ListViewItem(ne w string[]
{ie.LocationNam e, 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 InternetExplore r 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
ListViewItem s.
Each ListViewItem will equate to a row in the ListView which in turn will
equate to a single element of your Arraylist of InternetExplore r objects.

foreach (InternetExplor er ie in ar)
{
listView1.Items .Add(New ListViewItem(ne w string[] {ie.LocationNam e,
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********@my way.comwrote in message
news:11******* *************** @16g2000cwy.goo glegroups.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 (InternetExplor er ie in new ShellWindows())
{
Int32 iLocation = ie.FullName.Ind exOf("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 InternetExplore r
(again i don't understand the type, but have managed to get it to
work).

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

ie.FullName.Ind exOf

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.Collecti ons;
using System.Collecti ons.Generic;
using System.Componen tModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows. Forms;
using SHDocVw;

namespace InternetExplore rInterface
{
public partial class Form1 : Form
{
public Form1()
{
InitializeCompo nent();
}

private void Form1_Load(obje ct sender, EventArgs e)
{
ArrayList ar = new ArrayList();
foreach (InternetExplor er ie in new ShellWindows())
{
Int32 iLocation = ie.FullName.Ind exOf("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********@myw ay.comwrote in message
news:11******** *************@j 44g2000cwa.goog legroups.com...
Hi Stephany I tried that but it's not working.

It says ' missing ) '

I have:

foreach (InternetExplor er ie in ar)
{

listView1.Items .Add(New ListViewItem(ne w string[]
{ie.LocationNam e, 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 InternetExplore r 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 InternetExplore r objects.

foreach (InternetExplor er ie in ar)
{
listView1.Items .Add(New ListViewItem(ne w string[] {ie.LocationNam e,
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********@myw ay.comwrote in message
news:11******** **************@ 16g2000cwy.goog legroups.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 (InternetExplor er ie in new ShellWindows())
{
Int32 iLocation = ie.FullName.Ind exOf("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 InternetExplore r
(again i don't understand the type, but have managed to get it to
work).

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

ie.FullName.Ind exOf

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.Collecti ons;
using System.Collecti ons.Generic;
using System.Componen tModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows. Forms;
using SHDocVw;

namespace InternetExplore rInterface
{
public partial class Form1 : Form
{
public Form1()
{
InitializeCompo nent();
}

private void Form1_Load(obje ct sender, EventArgs e)
{
ArrayList ar = new ArrayList();
foreach (InternetExplor er ie in new ShellWindows())
{
Int32 iLocation = ie.FullName.Ind exOf("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********@mywa y.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********@myw ay.comwrote in message
news:11******** *************@j 44g2000cwa.goog legroups.com...
Hi Stephany I tried that but it's not working.
>
It says ' missing ) '
>
I have:
>
foreach (InternetExplor er ie in ar)
{
>
listView1.Items .Add(New ListViewItem(ne w string[]
{ie.LocationNam e, 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********@mywa y.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********@myw ay.comwrote in message
news:11******** *************@j 44g2000cwa.goog legroups.com...
Hi Stephany I tried that but it's not working.
>
It says ' missing ) '
>
I have:
>
foreach (InternetExplor er ie in ar)
{
>
listView1.Items .Add(New ListViewItem(ne w string[]
{ie.LocationNam e, ie.LocationURL} )) ;
}
>
>Gary!
>>
Nov 30 '06 #10

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

Similar topics

3
2810
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() { listView.View = View.Details; ArrayList LVcolTitles= new ArrayList(); LVcolTitles.Add("Drive"); LVcolTitles.Add("Cust");
1
1853
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. all help is appreciated. public void initList() { listView1.Enabled = true;
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...
7
6448
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 I need to do in a different way this would just make everything significantly cleaner and eaasier...
2
8614
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 looks awful when it's running - flickering too much!!! Anyone know how to solve this flickering problem? or how should I deal with this issue? I see some other C++ app can display more than 100 items without any flickering in such as speed. Can...
2
2528
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 items into that listview as Item1 - Item49, add a timer to your windows form, set the timer interval to 100 ms, in the event handler, add the code to update the value and timestamp Random r = new Random(); listView1.BeginUpdate();
2
9842
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 listview1.ListItems If ListItem.Checked = True Then listbox1.AddItem ListItem.Text next
1
1433
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 to, so when I change something in that listview all listviews who points to that listview must be updated.. But I don't have a idea why it isn't working.. I tried to make a singeton listview class and get a instance on the form
7
5116
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 text and a set of textboxes.
0
8858
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8738
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
9376
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
9148
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
9085
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6678
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
4499
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
3207
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
3
2146
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.