的WinForms ListView控件不显示在DetailsView控件项目 [英] winforms listview not showing items in detailsview

查看:148
本文介绍了的WinForms ListView控件不显示在DetailsView控件项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我又立刻陷入....

i'm stuck....

这是我的code项添加到我的列表视图:

this my code to add items to my listview:

ListViewItem item = new ListViewItem(ProjectDomainName);
item.Tag = relatedProject.ProjectId;
lvwSelectedProjects.Items.Add(item);

当我选择'View.List 作为视图模式,我看到的所有项目。

when i choose 'View.List' as viewmode, i see all items.

当我选择'View.Details (这是我想要的设置)我看到....什么。好了,什么都没有,我得到一个垂直滚动条,但没有任何项目。我可以过滚动,但没有项目....

When i choose 'View.Details' (which is the setting that i want) i see.... nothing. Well, nothing, i DO get a vertical scrollbar, but no items. And i can scroll too, but no items....

我也ListView中添加一列(没有改变添加项目code),但也没有工作。

I also added a column in the listview (didn't change the add items code), but that also didn't work

我必须忽视的东西?

推荐答案

这code为我工作:

using System;
using System.Windows.Forms;

public class LVTest : Form {
    public LVTest() {
        ListView lv = new ListView();
        lv.Columns.Add("Header", 100);
        lv.Columns.Add("Details", 100);
        lv.Dock = DockStyle.Fill;
        lv.Items.Add(new ListViewItem(new string[] { "Alpha", "Some details" }));
        lv.Items.Add(new ListViewItem(new string[] { "Bravo", "More details" }));
        lv.View = View.Details;
        Controls.Add(lv);
    }
}

public static class Program {
    [STAThread] public static void Main() {
        Application.Run(new LVTest());
    }
}

试试这个code为自己在一个空项目。然后,专注于它适应您的应用程序:比较你的程序是如何从这个code不同,在将其更改为更紧密地配合我的工作。这是确定的,如果你失去了你的程序功能;只是试图得到一个基本版本的工作。然后,通过比特添加功能回到位,所以你可以确保程序仍然工作的每一步。

Try this code for yourself in an empty project. Then, focus on adapting it to your application: compare how your program is different from this code, and work on changing it to more closely match mine. It's OK if you lose functionality in your program; just try to get a basic version working. Then, add functionality back bit by bit so you can be sure that the program still works every step of the way.

如果你仍然坚持,在你的项目发布更多code和我们可能有,为什么你遇到问题的一个更好的主意。

If you're still stuck, post more code from your project and we might have a better idea of why you're having trouble.

这篇关于的WinForms ListView控件不显示在DetailsView控件项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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