Re: ListView Problem - better explanation i hope



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.


<garyusenet@xxxxxxxxx> wrote in message
news:1164888084.951191.98750@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
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.



<garyusenet@xxxxxxxxx> wrote in message
news:1164880056.770686.302280@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
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);
}


}
}
}




.



Relevant Pages

  • Re: ListView Problem - better explanation i hope
    ... The ListView is a Windows control that you drag from the toolboz and drop ... If you haven't got a window number in your InternetExplorer object then ... Internet Explorer windows that are open on my computer. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: ListView Problem - better explanation i hope
    ... The ListView is a Windows control that you drag from the toolboz and drop it ... If you haven't got a window number in your InternetExplorer object then I ... Internet Explorer windows that are open on my computer. ...
    (microsoft.public.dotnet.languages.csharp)
  • ListView Problem - better explanation i hope
    ... Internet Explorer windows that are open on my computer. ... would seem that the listview control is the best way of doing this. ...
    (microsoft.public.dotnet.languages.csharp)
  • Explorer Suchfunktion hängt
    ... Den Internetexplorer erneut installiert. ... Weiterhin vermutete ich das vielleicht der Indexdienst ... Die wirkliche letze Rettung wäre wohl eine Windows 2000 ... >Möchte ich mit der Windows Suche nach Dateien ...
    (microsoft.public.de.german.win2000.sonstiges)
  • Re: Bugs in SP2?
    ... Christian Göller schrieb: ... dass der Internetexplorer angezeigt werden soll. ... > auf dem Laptop (Windows XP Home). ... AntiVir war auf dem Laptop ein bisschen akuteller als auf dem ...
    (microsoft.public.de.german.windowsxp.setup)