473,320 Members | 2,048 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,320 software developers and data experts.

Casting error when iterating through listview in WPF

When i try to iterate through a populated WPF listview in order to remove a selected item, i get this weird, none sense of an error: cant cast string to listviewitem. (now I know what the error is implying, however; here is my code)

Expand|Select|Wrap|Line Numbers
  1. For each titem as listviewitem in listview1.items
  2.  if titem.isselected then listview1.items.remove(titem)
  3. next
  4.  
The error that I am getting is at the "for each line", (where titem iterates through the list. So my question is this: If my logic is correct and the coding is correct why am i getting that casting error when I am not dealing with strings?
Oct 9 '11 #1
0 1164

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Bryce | last post by:
First off, I hope I am posting this in the correct place Convert.ToDecimal() is throwing a FormatException, as is Decimal.Parse() if I send in the string "000063.27" or "+000063.27". I tried...
2
by: pb | last post by:
Hi, I'm having problems deploying a project to win2003. It is currently on win2000 server and works fine - it also works fine on my development machine - win2003. Both my machine and the new...
3
by: Rookie | last post by:
Hi, Is there any way I can keep an item in a ListView higlighted even when the ListView does not have focus. eg. If the user is modifying the row by entering values in a TextBox then the...
12
by: Dica | last post by:
i can't seem to find a way to cast the value in my comboBox to integer. i've tried the following: short iProjectID = Convert.ToInt16(cboProjects.SelectedValue); i keep getting a "Sepcified...
6
by: Thomas Connolly | last post by:
I have 2 pages referencing the same codebehind file in my project. Originally the pages referenced separate code behind files. Once I changed the reference to the same file, everything worked...
0
by: Mo | last post by:
Hi, I'm getting an error: Input string was not in a correct format This happens when I try to sort a column. It seems that the sort event handler claims that the sort expression is not in...
2
by: DCC700 | last post by:
VS 2005 Converted Header causing error when publishing After converting from Visual Studio 2003 to 2005, I have had several issues with a header that is used throughout the project. The...
2
by: =?Utf-8?B?U2hhcm9u?= | last post by:
I'm using a Bitmap that has a palette of 256 colors (256 bytes). I'm taking the Bitmap data by: System.Drawing.Imaging.BitmapData refData = myBitmap.LockBits(new Rectangle(0, 0, bmp.Width,...
0
by: John | last post by:
Listview works fine by itself, but produces this error when I drop it into an update panel? error BC30311: Value of type 'System.Web.UI.HtmlControls.HtmlTableCell' cannot be converted to...
1
by: Anjum Rizwi | last post by:
protected T ExecuteScalar<T>(DbCommand cmd) { object obj; try { obj = db.ExecuteScalar(cmd); return (T) obj; } catch {
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.