日期:2014-05-18  浏览次数:20739 次

怎么往ListView加项目?
我设置了三个ListView,ListView1,ListView2,ListView3.ListView1里的项目是文字1,2,3;ListView2里的项目是图片A,B,C.比如,我想点击ListView1里的1,再点击ListView2里的A,怎么在能让ListView3里出现一项是1A?就是文字加图片的

------解决方案--------------------
ListViewItem lvi=new ListViewItem ();

可以在构造函数里做。也可以设置属性!!


然后listview3.items。add(lvi);
------解决方案--------------------
this.ListView2.LargeImageList=this.imageList1;
this.ListView3.LargeImageList=this.imageList1;
C# code

        private void listView2_MouseClick(object sender, MouseEventArgs e)
        {
            ListViewItem tem = this.listView2.GetItemAt(e.X, e.Y);
            if (tem.Index != -1&&this.listView1.SelectedItems[0] != null)
                this.listView3.Items.Add(this.listView1.SelectedItems[0].Text, this.listView2.SelectedItems[0].ImageIndex);
        }