473,387 Members | 1,844 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

how can i get the index of a selected listview item and index a related arraylist item?

in a different app, i can grab the index of a ListBox, but when i try
it with a listview with only one column, i'm having issues.

the first line (string) below works as expected.
the second line (string), i want the index of the fField arraylist. i
just have a 0 in there
at this point...i would think there is something similar to indexing a
listbox,
such as lvProductSelection.SelectedIndex
string dTest =
lvProductSelection.SelectedItems[0].ToString().Replace("'", "''");
string iTest = fField[0].ToString().Replace("'", "''");
as usual, i'm probably making this harder than it needs to be.

i appreciate any input...

thanks everyone...

Nov 9 '06 #1
2 2296
hI,

The listview is different, you do not have the SelectedXXXX members
instead each ListViewItem has a Selected property.

You have to iterate to get the selected elements

"forest demon" wrote:
in a different app, i can grab the index of a ListBox, but when i try
it with a listview with only one column, i'm having issues.

the first line (string) below works as expected.
the second line (string), i want the index of the fField arraylist. i
just have a 0 in there
at this point...i would think there is something similar to indexing a
listbox,
such as lvProductSelection.SelectedIndex
string dTest =
lvProductSelection.SelectedItems[0].ToString().Replace("'", "''");
string iTest = fField[0].ToString().Replace("'", "''");
as usual, i'm probably making this harder than it needs to be.

i appreciate any input...

thanks everyone...

Nov 9 '06 #2

ignacio machin wrote:
hI,

The listview is different, you do not have the SelectedXXXX members
instead each ListViewItem has a Selected property.

You have to iterate to get the selected elements

"forest demon" wrote:
in a different app, i can grab the index of a ListBox, but when i try
it with a listview with only one column, i'm having issues.

the first line (string) below works as expected.
the second line (string), i want the index of the fField arraylist. i
just have a 0 in there
at this point...i would think there is something similar to indexing a
listbox,
such as lvProductSelection.SelectedIndex
string dTest =
lvProductSelection.SelectedItems[0].ToString().Replace("'", "''");
string iTest = fField[0].ToString().Replace("'", "''");
as usual, i'm probably making this harder than it needs to be.

i appreciate any input...

thanks everyone...
i got it figured out.

thanks for your input ignacio...

Nov 10 '06 #3

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

Similar topics

1
by: Jim McLeod | last post by:
Dear Group How am I going wrong with this drag and drop procedure.. private void ResourceList_ItemDrag(object sender, System.Windows.Forms.ItemDragEventArgs e System.Windows.Forms.ListView...
5
by: Søren Reinke | last post by:
Hi everyone. In a little program i am writing i have a listview, i fill it with data from an ArrayList which contains a lot of objects. The data for the columns are differente fields in the...
7
by: Visual Systems AB \(Martin Arvidsson\) | last post by:
Hi! I'v been struggeling with removing selected items from a listview. Anyone that can give me a piece of code that does this? I am a newbee to this C# and cant figure it out.... Regards...
2
by: Mamatha | last post by:
Hi I have an application with listview.When i click on one button the data will be displayed like this in the listview: colA colB colC ----- ----- ------...
0
by: Graham | last post by:
Hi everyone I have a form which contains a ListView control. The code handles the SelectedIndexChanged event, and changes some icons on some items in the ListView. I've found that when I...
11
by: Santosh | last post by:
Dear all , i am writting following code. if(Page.IsPostBack==false) { try { BindSectionDropDownlist();
12
by: garyusenet | last post by:
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. ...
2
by: =?Utf-8?B?R2lkaQ==?= | last post by:
Hi, I'm trying to get the index of a selected Item in ListView. I'm using the SelectedItemChange Event, but i can't get the item index (like in listbox for i.e). How can i get the index? ...
0
by: =?Utf-8?B?TWlrZSBDb2xsaW5z?= | last post by:
I have a listview that when I select an item, it populates a details view. I want to show the item that was selected in the listview by changing it to yellow. Trouble is, the selected item does not...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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,...

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.