473,851 Members | 2,323 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 3780
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 SelectedIndexChanged event cannot be cancelled, and it's actually called for each change in the selection. So,...
1
3412
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 don't know how to make an item be selected without the user actually clicking on a line. For a...
6
2546
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
3079
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 the newly selected item is a selectable one, if it's not, I try to change the selection like so.
1
2063
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
5563
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 disable if I click off the text of the items in the listview but still within about 10-20 pixels of...
5
12678
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 (approx. 500 items) or selecting with mouse, for each item selected through all listview an event...
12
4045
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 MouseUp event. After the first item is selected and another item clicked on, both the...
4
7470
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 and only the new look of the ListViewItem after the trigger takes effect shows what Item is...
0
9895
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
9744
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
11011
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...
0
10670
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9503
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7900
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
7072
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5931
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3178
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.