listview item selection..??

  • Thread starter Thread starter Maheshkumar.R
  • Start date Start date
M

Maheshkumar.R

hi groups,

I have placed an listview control, i want to iterate thru the control and find the clicked event items.

listView2.Items.Add(fname.ToString(), i);

how i can perform the iteration to find the item clicked...? and its item.

thankz--
Mähésh Kumär. R
 
Hi,

You can use the SelectedIndexChanged event with the SelectedIndices/SelectedItems properties to find the selected items.

If you really want to use the Mouse position in a Click event, or need to find out which subitem was clicked in detail view, you can use

Point p = listView1.PointToClient(Control.MousePosition);
ListViewItem l = listView1.GetItemAt(p.X, p.Y);


hi groups,

I have placed an listview control, i want to iterate thru the control and find the clicked event items.

listView2.Items.Add(fname.ToString(), i);

how i can perform the iteration to find the item clicked...? and its item.

thankz--
Mähésh Kumär. R
 
{

{

Image imp=new Bitmap(bmp);

Image thumbnail = imp.GetThumbnailImage(300, 300, null, new Inept());

imageless.Images.Add(thumbnail);

listView2.Items.Add(fame.To(), I);

}



Here I want to handle the Click event of a pictures in the list
control,like explorer...if I click thumbnail privet off picture in left
pane, when I click it should display as full image in the right pane is my
requirements,

please guide

Maheshkumar.OR









Morten Wennevik said:
Hi,

You can use the SelectedIndexChanged event with the
SelectedIndices/SelectedItems properties to find the selected items.
If you really want to use the Mouse position in a Click event, or need to
find out which subitem was clicked in detail view, you can use
Point p = listView1.PointToClient(Control.MousePosition);
ListViewItem l = listView1.GetItemAt(p.X, p.Y);


hi groups,

I have placed an listview control, i want to iterate thru the control and find the clicked event items.

listView2.Items.Add(fname.ToString(), i);

how i can perform the iteration to find the item clicked...? and its item.

thankz--
Mähésh Kumär. R

 
I'm afraid I don't understand.

Do you have a listView in the left pane of image thumbnails (icons), and if one of the thumbnails are selected (clicked), display the full image in the right pane?

If so, store a reference to the full image in the ListViewItem.Tag property, and use this reference to display the full image.


{

{

Image imp=new Bitmap(bmp);

Image thumbnail = imp.GetThumbnailImage(300, 300, null, new Inept());

imageless.Images.Add(thumbnail);

listView2.Items.Add(fame.To(), I);

}



Here I want to handle the Click event of a pictures in the list
control,like explorer...if I click thumbnail privet off picture in left
pane, when I click it should display as full image in the right pane is my
requirements,

please guide

Maheshkumar.OR









Morten Wennevik said:
Hi,

You can use the SelectedIndexChanged event with the
SelectedIndices/SelectedItems properties to find the selected items.
If you really want to use the Mouse position in a Click event, or need to
find out which subitem was clicked in detail view, you can use
Point p = listView1.PointToClient(Control.MousePosition);
ListViewItem l = listView1.GetItemAt(p.X, p.Y);


hi groups,

I have placed an listview control, i want to iterate thru the control and find the clicked event items.

listView2.Items.Add(fname.ToString(), i);

how i can perform the iteration to find the item clicked...? and its item.

thankz--
Mähésh Kumär. R

 
Even i'm confused..:)..thanks for your reply.

In simple way- let say i'm having 10 items in my list item. how i can find
the particular image has been selected in that list of 10 items.Items may
vary.., at runtime, i should iterate thru collection and get my list
item...how ??
i mean, is there any method or way to get my user selected item in my
dynamic listitem..?

thankz
Maheshkumar.R


Morten Wennevik said:
I'm afraid I don't understand.

Do you have a listView in the left pane of image thumbnails (icons), and
if one of the thumbnails are selected (clicked), display the full image in
the right pane?
If so, store a reference to the full image in the ListViewItem.Tag
property, and use this reference to display the full image.
{

{

Image imp=new Bitmap(bmp);

Image thumbnail = imp.GetThumbnailImage(300, 300, null, new Inept());

imageless.Images.Add(thumbnail);

listView2.Items.Add(fame.To(), I);

}



Here I want to handle the Click event of a pictures in the list
control,like explorer...if I click thumbnail privet off picture in left
pane, when I click it should display as full image in the right pane is my
requirements,

please guide

Maheshkumar.OR









Morten Wennevik said:
Hi,

You can use the SelectedIndexChanged event with the
SelectedIndices/SelectedItems properties to find the selected items.
If you really want to use the Mouse position in a Click event, or need
to
find out which subitem was clicked in detail view, you can use
Point p = listView1.PointToClient(Control.MousePosition);
ListViewItem l = listView1.GetItemAt(p.X, p.Y);


hi groups,

I have placed an listview control, i want to iterate thru the control
and find the clicked event items.
listView2.Items.Add(fname.ToString(), i);

how i can perform the iteration to find the item clicked...? and its item.

thankz--
Mähésh Kumär. R

 
Well, as I said in an earlier post, there is ListView.SelectedItems/SelectedIndices or using ListView.GetItemAt(Point)

When an item is selected, the SelectedIndexChanged event is triggered. In this event, call the SelectedItems property of the ListView.

What I suspect you want to do is to add a reference to an image or a filename for each ListViewItem you add to the ListView. I don't know what you are putting in the ListView as the line 'listView2.Items.Add(fame.To(), I)' doesn't tell me much, but you could do something like this:

string[] filenames = Directory.GetFiles(path);
foreach(string s in filenames)
{
ListViewItem lvi = new ListViewItem(s);
lvi.Tag = s;

listView1.Items.Add(s);
}

In the SelectedIndexChanged event, you could do something like

private void listView1_SelectedIndexChanged(object sender, EventArgs e)
{
if(listView1.SelectedItems.Count == 0)
return;

ListViewItem lvi = listView1.SelectedItems[0];
string s = (string)lvi.Tag;
// Image i = Image.FromFile(s);
}


Of course, in this particular example you could simply use the Text property to get the filename.


Even i'm confused..:)..thanks for your reply.

In simple way- let say i'm having 10 items in my list item. how i can find
the particular image has been selected in that list of 10 items.Items may
vary.., at runtime, i should iterate thru collection and get my list
item...how ??
i mean, is there any method or way to get my user selected item in my
dynamic listitem..?

thankz
Maheshkumar.R


Morten Wennevik said:
I'm afraid I don't understand.

Do you have a listView in the left pane of image thumbnails (icons), and
if one of the thumbnails are selected (clicked), display the full image in
the right pane?
If so, store a reference to the full image in the ListViewItem.Tag
property, and use this reference to display the full image.
{

{

Image imp=new Bitmap(bmp);

Image thumbnail = imp.GetThumbnailImage(300, 300, null, new Inept());

imageless.Images.Add(thumbnail);

listView2.Items.Add(fame.To(), I);

}



Here I want to handle the Click event of a pictures in the list
control,like explorer...if I click thumbnail privet off picture in left
pane, when I click it should display as full image in the right pane is my
requirements,

please guide

Maheshkumar.OR









Hi,

You can use the SelectedIndexChanged event with the
SelectedIndices/SelectedItems properties to find the selected items.

If you really want to use the Mouse position in a Click event, or need to
find out which subitem was clicked in detail view, you can use

Point p = listView1.PointToClient(Control.MousePosition);
ListViewItem l = listView1.GetItemAt(p.X, p.Y);
wrote:

hi groups,

I have placed an listview control, i want to iterate thru the control
and find the clicked event items.

listView2.Items.Add(fname.ToString(), i);

how i can perform the iteration to find the item clicked...? and its
item.

thankz--
Mähésh Kumär. R

 
(Sat, 23 Jul 2005 15:35:09 +0530), "Maheshkumar.R"
In simple way- let say i'm having 10 items in my list item. how i can find
the particular image has been selected in that list of 10 items.Items may
vary.., at runtime, i should iterate thru collection and get my list
item...how ??
i mean, is there any method or way to get my user selected item in my
dynamic listitem..?

I must be missing something, 'cause I really don't understand your
problem. Morten's trick (using a reference to the full image in the
ListViewItem.Tag property) seems to solve the puzzle. Even if your
list is dynamic, the Tag property of each item should be consistent...

So all you need to do is to handle the SelectedIndexChanged event of
your ListView: the SelectedItems property of the event object will
give you an access point to the image reference through the Tag
property.
 
Thnkz a lot Morten Wennevik,exactly i solved my problem thru ur approach. I
used tag for each item and got it..
thnks to all,
Maheshkumar.R
 
Back
Top