473,799 Members | 2,741 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Casting error when iterating through listview in WPF

1 New Member
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 1175

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

Similar topics

5
1532
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 removing the zeroes (via substring) and this doesn't work either Any ideas Thanks in advance.
2
1520
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 machine are running .net 1.1 sp1. I get an error when I try to descrialize a file (with code): XmlTextReader reader = new XmlTextReader(fileName);
3
9110
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 TextBox has focus, but I still want the corresponding row in the ListView to be higlighted. Is this possible? Hope to hear from someone out there. Links to articles that describe
12
4718
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 cast is not allowed" error. how can i do this?
6
2862
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 fine while the file was in the project directory. When the obsolete file was removed from the project directory, my application will no longer compile. Can someone please help with this issue? Thank in advance, Tom
0
1289
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 String format, but it is. Any suggestions would be greatly appreciated 'DATAGRID code:
2
1709
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 conversion automatically created an abstract base class for the header in the Migrated folder of the App_Code directory. One of the major problems this caused was regarding the fact that I pass the header to a standard error handling class to process the...
2
2420
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, bmp.Height), System.Drawing.Imaging.ImageLockMode.WriteOnly, bmp.PixelFormat); byte* buff = refData.Scan0.ToPointer(); And on this buff I'm iterating to set its data.
0
1167
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 'System.Web.UI.HtmlControls.HtmlTableRow' Thanks John
1
1208
by: Anjum Rizwi | last post by:
protected T ExecuteScalar<T>(DbCommand cmd) { object obj; try { obj = db.ExecuteScalar(cmd); return (T) obj; } catch {
0
9544
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
10490
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
10259
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...
1
10238
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7570
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
6809
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
5589
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3761
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2941
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.