如何从其他表单将信息添加到Objectlistview [英] how to add infos to Objectlistview from another form

查看:127
本文介绍了如何从其他表单将信息添加到Objectlistview的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了Objectlistview的问题,当我向表单添加信息时,它没有添加到Objectlistview中,并且向我显示了以下消息:
System.InvalidCastException:无法将类型为"System.Windows.Forms.ListViewItem"的对象转换为类型为"BrightIdeasSoftware.OLVListItem"的对象.
这是我的代码:

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));

推荐答案

请不要尝试将BrightIdeasSoftware的组件与.NET库的组件混合使用.您已明确指出它们不兼容.或者,克隆项目的纯数据内容,然后包装在不同类型的项目中.使用统一的方法比解决该问题的方法更可取.

—SA
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


这篇关于如何从其他表单将信息添加到Objectlistview的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆