473,581 Members | 2,785 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

listview item selection..??

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[i].ToString(), i);

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

thankz--
Mähésh Kumär. R
Nov 17 '05 #1
13 3746
Hi,

You can use the SelectedIndexCh anged 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.Point ToClient(Contro l.MousePosition );
ListViewItem l = listView1.GetIt emAt(p.X, p.Y);
On Sat, 23 Jul 2005 09:42:41 +0200, Maheshkumar.R <cy**********@y ahoo.com> 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[i].ToString(), i);

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

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


--
Happy coding!
Morten Wennevik [C# MVP]
Nov 17 '05 #2
Hi,

You can use the SelectedIndexCh anged 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.Point ToClient(Contro l.MousePosition );
ListViewItem l = listView1.GetIt emAt(p.X, p.Y);
On Sat, 23 Jul 2005 09:42:41 +0200, Maheshkumar.R <cy**********@y ahoo.com> 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[i].ToString(), i);

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

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


--
Happy coding!
Morten Wennevik [C# MVP]
Nov 17 '05 #3
{

{

Image imp=new Bitmap(bmp);

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

imageless.Image s.Add(thumbnail );

listView2.Items .Add(fame[i].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" <Mo************ @hotmail.com> wrote in message
news:op.sucyjra 5klbvpo@stone.. .
Hi,

You can use the SelectedIndexCh anged 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.Point ToClient(Contro l.MousePosition );
ListViewItem l = listView1.GetIt emAt(p.X, p.Y);
On Sat, 23 Jul 2005 09:42:41 +0200, Maheshkumar.R <cy**********@y ahoo.com> 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[i].ToString(), i);

how i can perform the iteration to find the item clicked...? and its item.
thankz--
Mähésh Kumär. R


--
Happy coding!
Morten Wennevik [C# MVP]

Nov 17 '05 #4
{

{

Image imp=new Bitmap(bmp);

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

imageless.Image s.Add(thumbnail );

listView2.Items .Add(fame[i].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" <Mo************ @hotmail.com> wrote in message
news:op.sucyjra 5klbvpo@stone.. .
Hi,

You can use the SelectedIndexCh anged 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.Point ToClient(Contro l.MousePosition );
ListViewItem l = listView1.GetIt emAt(p.X, p.Y);
On Sat, 23 Jul 2005 09:42:41 +0200, Maheshkumar.R <cy**********@y ahoo.com> 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[i].ToString(), i);

how i can perform the iteration to find the item clicked...? and its item.
thankz--
Mähésh Kumär. R


--
Happy coding!
Morten Wennevik [C# MVP]

Nov 17 '05 #5
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.Ta g property, and use this reference to display the full image.
On Sat, 23 Jul 2005 10:59:25 +0200, Maheshkumar.R <cy**********@y ahoo.com> wrote:
{

{

Image imp=new Bitmap(bmp);

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

imageless.Image s.Add(thumbnail );

listView2.Items .Add(fame[i].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" <Mo************ @hotmail.com> wrote in message
news:op.sucyjra 5klbvpo@stone.. .
Hi,

You can use the SelectedIndexCh anged 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.Point ToClient(Contro l.MousePosition );
ListViewItem l = listView1.GetIt emAt(p.X, p.Y);
On Sat, 23 Jul 2005 09:42:41 +0200, Maheshkumar.R <cy**********@y ahoo.com>

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[i].ToString(), i);
>
> how i can perform the iteration to find the item clicked...? and its item. >
> thankz--
> Mähésh Kumär. R
>
>


--
Happy coding!
Morten Wennevik [C# MVP]



--
Happy coding!
Morten Wennevik [C# MVP]
Nov 17 '05 #6
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.Ta g property, and use this reference to display the full image.
On Sat, 23 Jul 2005 10:59:25 +0200, Maheshkumar.R <cy**********@y ahoo.com> wrote:
{

{

Image imp=new Bitmap(bmp);

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

imageless.Image s.Add(thumbnail );

listView2.Items .Add(fame[i].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" <Mo************ @hotmail.com> wrote in message
news:op.sucyjra 5klbvpo@stone.. .
Hi,

You can use the SelectedIndexCh anged 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.Point ToClient(Contro l.MousePosition );
ListViewItem l = listView1.GetIt emAt(p.X, p.Y);
On Sat, 23 Jul 2005 09:42:41 +0200, Maheshkumar.R <cy**********@y ahoo.com>

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[i].ToString(), i);
>
> how i can perform the iteration to find the item clicked...? and its item. >
> thankz--
> Mähésh Kumär. R
>
>


--
Happy coding!
Morten Wennevik [C# MVP]



--
Happy coding!
Morten Wennevik [C# MVP]
Nov 17 '05 #7
Even i'm confused..:)..t hanks 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" <Mo************ @hotmail.com> wrote in message
news:op.suc1icp gklbvpo@stone.. .
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.Ta g property, and use this reference to display the full image.

On Sat, 23 Jul 2005 10:59:25 +0200, Maheshkumar.R <cy**********@y ahoo.com> wrote:
{

{

Image imp=new Bitmap(bmp);

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

imageless.Image s.Add(thumbnail );

listView2.Items .Add(fame[i].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" <Mo************ @hotmail.com> wrote in message
news:op.sucyjra 5klbvpo@stone.. .
Hi,

You can use the SelectedIndexCh anged 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.Point ToClient(Contro l.MousePosition );
ListViewItem l = listView1.GetIt emAt(p.X, p.Y);
On Sat, 23 Jul 2005 09:42:41 +0200, Maheshkumar.R
<cy**********@y ahoo.com> 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[i].ToString(), i);
>
> how i can perform the iteration to find the item clicked...? and its

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

--
Happy coding!
Morten Wennevik [C# MVP]



--
Happy coding!
Morten Wennevik [C# MVP]

Nov 17 '05 #8
Even i'm confused..:)..t hanks 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" <Mo************ @hotmail.com> wrote in message
news:op.suc1icp gklbvpo@stone.. .
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.Ta g property, and use this reference to display the full image.

On Sat, 23 Jul 2005 10:59:25 +0200, Maheshkumar.R <cy**********@y ahoo.com> wrote:
{

{

Image imp=new Bitmap(bmp);

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

imageless.Image s.Add(thumbnail );

listView2.Items .Add(fame[i].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" <Mo************ @hotmail.com> wrote in message
news:op.sucyjra 5klbvpo@stone.. .
Hi,

You can use the SelectedIndexCh anged 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.Point ToClient(Contro l.MousePosition );
ListViewItem l = listView1.GetIt emAt(p.X, p.Y);
On Sat, 23 Jul 2005 09:42:41 +0200, Maheshkumar.R
<cy**********@y ahoo.com> 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[i].ToString(), i);
>
> how i can perform the iteration to find the item clicked...? and its

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

--
Happy coding!
Morten Wennevik [C# MVP]



--
Happy coding!
Morten Wennevik [C# MVP]

Nov 17 '05 #9
Well, as I said in an earlier post, there is ListView.Select edItems/SelectedIndices or using ListView.GetIte mAt(Point)

When an item is selected, the SelectedIndexCh anged 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.Item s.Add(fame[i].To(), I)' doesn't tell me much, but you could do something like this:

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

listView1.Items .Add(s);
}

In the SelectedIndexCh anged event, you could do something like

private void listView1_Selec tedIndexChanged (object sender, EventArgs e)
{
if(listView1.Se lectedItems.Cou nt == 0)
return;

ListViewItem lvi = listView1.Selec tedItems[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.
On Sat, 23 Jul 2005 12:05:09 +0200, Maheshkumar.R <cy**********@y ahoo.com> wrote:
Even i'm confused..:)..t hanks 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" <Mo************ @hotmail.com> wrote in message
news:op.suc1icp gklbvpo@stone.. .
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.Ta g

property, and use this reference to display the full image.


On Sat, 23 Jul 2005 10:59:25 +0200, Maheshkumar.R <cy**********@y ahoo.com>

wrote:
> {
>
> {
>
> Image imp=new Bitmap(bmp);
>
> Image thumbnail = imp.GetThumbnai lImage(300, 300, null, new Inept());
>
> imageless.Image s.Add(thumbnail );
>
> listView2.Items .Add(fame[i].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" <Mo************ @hotmail.com> wrote in message
> news:op.sucyjra 5klbvpo@stone.. .
>> Hi,
>>
>> You can use the SelectedIndexCh anged 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.Point ToClient(Contro l.MousePosition );
>> ListViewItem l = listView1.GetIt emAt(p.X, p.Y);
>>
>>
>> On Sat, 23 Jul 2005 09:42:41 +0200, Maheshkumar.R <cy**********@y ahoo.com> > 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[i].ToString(), i);
>> >
>> > how i can perform the iteration to find the item clicked...? and its
> item.
>> >
>> > thankz--
>> > Mähésh Kumär. R
>> >
>> >
>>
>>
>>
>> --
>> Happy coding!
>> Morten Wennevik [C# MVP]
>
>
>


--
Happy coding!
Morten Wennevik [C# MVP]



--
Happy coding!
Morten Wennevik [C# MVP]
Nov 17 '05 #10

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

Similar topics

8
602
by: InvisibleDuncan | last post by:
I have a ListView that populates some fields whenever the user selects an item. However, if they change the data in the fields and then select a new item without saving, I want to display a message box that warns that their changes will be lost, and asks them to confirm whether to continue. Sounds simple Unfortunately, the ListView's...
1
3396
by: Bob Geltz | last post by:
I am able to populate a ListView with several detail lines (several columns). When finished, I would like to pre-select the first item in the list (before the user interacts with the list). This way, if a user clicks on the OK button, there will be a default selection. I know how to use ListView.SelectedItems to get the selection, I just...
6
2523
by: Vanessa | last post by:
With this program I can do one selection, but upon the second I get an error where ///////////////// is indicated. Please help. using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data;
5
810
by: joseph.inglis | last post by:
Hi group, Someones gonna answer this in two seconds flat but im tearing my hair out. Create a form, add a listview, add 5 items and programmatically select item at index 3. this.imageList.Items.EnsureVisible(); this.imageList.Items.Selected = true; That works fine. Use the mouse to select index 4 and again, works sweetly.
1
3060
by: youngie | last post by:
I've got a listview on a form in report style. It's populated with 40 item. I want to prevent the used clicking on some items, and if the user clicks on one of these items I want the selection to revert back to the old selection, hideselection property if false, listview is single select. In the OnSelectedChange() handler I test to see if...
1
2053
by: samoore33 | last post by:
I found this code on MSDN, and it works great. It creates a ListView dynamically and add items to it and all. It is great. I have changed a few of the column names to suit me. Dim listView1 As New ListView listView1.Bounds = New Rectangle(New Point(10, 10), New Size(300, 200)) ' Set the view to show details.
6
5528
by: Brandon McCombs | last post by:
Hello, I have a form that contains a listview on the left side and a column of buttons on the right side. Only some of the buttons do I want enabled all the time. The other buttons should be enabled only if something is selected in the listview. That part specifically works but not very well. It seems that I can only get the buttons to...
5
12647
by: Jure Bogataj | last post by:
Hi all! I have a problem (performance issue) with listview. I have implemented an ItemSelectionChange on my listview and put some code in it (I build some toolbar based on selection and update info in statusbar). When selecting one item (clicking on listview) it works fast, without noticing. However if selecting multiple items with SHIFT...
12
4005
by: Tom Bean | last post by:
I am trying to display a ContextMenuStrip when a user right-clicks on an item in a ListView and have encountered a something that seems strange to me. When the ListView is initially populated, no items are selected. When the first item is selected by clicking either the left or right button, the SelectedIndexChanged event fires but not the...
4
7452
by: Brandon | last post by:
HI all, I am working on a WPF listview that get items through the XMLDataProvider and making a listview with two actual columns and in both CellTemplete XAML in a grid bind more than one snippet of the XML data to the cell. Now this works fine no problem... When I try to setup a IsSelected trigger I lose the default listview selection UI...
0
7876
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...
0
7804
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...
0
8156
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. ...
0
8180
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...
0
6563
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5681
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...
1
2307
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
1
1409
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1144
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...

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.