列表视图中不可见的项目 [英] Items not Visible in listview

查看:89
本文介绍了列表视图中不可见的项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Good Day,
我有2个分别具有listviews(lstviewSource和lstviewTarget)的Windows窗体(form_source和form_target).从"listviewSource"中选择项目时,需要将其显示在"lstviewTarget"上.我正在克隆"form_source"中的列表视图中的项目,但未在"form_target"上的列表视图中显示.

下面是代码....在此先感谢. :confused:

****************************************************** ***

form_target
上的方法

Good Day ,
I have 2 windows forms (form_source and form_target) with listviews (lstviewSource and lstviewTarget) respectively. When the items from the "listviewSource" is selected it needs to be displayed on "lstviewTarget".I am cloning the items from the listview in "form_source" but it is not displaying on the listview on "form_target".

below is the code.... thanks in advance. :confused:

*****************************************************

method on form_target

public void CopySelectedItems(ListView _lstviewSource)
       {
           foreach (ListViewItem item in _lstviewSource.Items)
           {
               if (item.Checked)
               {
                 lstviewTarget.Items.Add((ListViewItem)item.Clone());
               }
           }
       }





****************************************************** ****


form_source上的方法





******************************************************


method on form_source

private void btnAddImages_Click(object sender, EventArgs e)
        {
            form_target myform = new form_target();
            myform.CopySelectedItems(lstviewSource);
            this.Close();
        }



****************************************************** ****



******************************************************

推荐答案

我愿意打赌,您将错误的listview对象传递给第二种形式.奇怪的是,它们在两种形式中都被命名为相同的东西.

第二个想法是您的克隆方法无法正常运行.

使用调试器会回答您的问题.
I would be willing to bet that you''re passing the wrong listview object to the 2nd form. It''s curious that they''re named the same thing in both forms.

A second thought is that your clone method is not functioning correctly.

Using the debugger would answer your question.


这篇关于列表视图中不可见的项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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