Click here to Skip to main content
15,896,606 members
Please Sign up or sign in to vote.
3.67/5 (2 votes)
See more:
i face problem with Objectlistview , when i add infos to the form it doesn't addd into Objectlistview , and it show me this message:
System.InvalidCastException: Unable to cast object of type 'System.Windows.Forms.ListViewItem' to type 'BrightIdeasSoftware.OLVListItem'.
this is my code :
           //add infos to the OLV
    string [] tab = new string[11];
    tab[0] = TbNumLocations.Text;
    tab[1] = CBListNomClient.Text;
    tab[2] = CBListMatriculeVoiture.Text;
    tab[3] = DtpDateLocation.Text;
    tab[4] = DtpDateRetour.Text;
    tab[5] = TbPrixLocation.Text;
    tab[6] = TbnbJourLocation.Text;
    tab[7] = sTotal.ToString();
    tab[8] = CbTypeGarantie.Text;
    tab[9] = TbMontantGarantie.Text;
    tab[10] = sIdTelephone.ToString();


_MForm.OlvLocationVoitures.Items.Add(new ListViewItem(tab)); //(new OLVListItem(tab));
Posted
Comments
Sergey Alexandrovich Kryukov 29-Dec-11 12:11pm    
Why are your trying to add an assignment-incompatible item? Any reason for doing so?
--SA

1 solution

Just don't try to mix components of BrightIdeasSoftware with those of .NET libraries. You've given a clear indication that they are incompatible. Alternatively, clone pure data content of the item and wrap in in the item of different type. Using uniform approach is preferable to that work-around.

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900