English 中文(简体)
名单 按方案分列的观点栏目显示项目类型
原标题:ListView programatically added columns shows type of item

我在另一组会议中发言,希望增加一栏。 清单中的项目是该组的一组物体。

When I add a column like this

var col : GridViewColumn = new GridViewColumn();
col.Header = "Header text";
list.View.Columns.Add(col);

清单表中各行各有新栏所列项目类型的名称。 即使我改变了新一栏(>>项目类别.Items[newColIdx] = “zz”)的价值,但这一数值并未显示。 没有数据约束或单元模板。

Why is that?

www.un.org/spanish/ga/president 1. 如果是一份名单,则该名单应提交。 项目包含一系列A类——你如何控制A类东西是如何在GridView中展示的? 我需要在这里进行反向工程,显示会员资格是无效的,因此它不使用具有约束力的数据。

<>Bounty Question:ToString(<>/code>, 每一项目(代表一行)均须问,如何将这一条放在GredView各栏上? 我怎样才能改变行文中的项目,以便填补新的一栏?

在试图找到这一解决办法时,特别问题是,这种解决办法在较大的C# .NET应用中,在J式沙箱中运行,除使用电文箱和反射外,还未提供脱硫的可能性。

Edit: The problem is that I am writing a JScript which runs in a 3rd party .NET application and gives me the opportunity to do many things possible with .NET. This is a script adding features to a listview. I can access the listview and it is filled with database data by the 3rd party app. I do not know how it does that. I can programatically add custom rows with custom content (not DB related). But when I add a custom column I do not seem to be able to se its value in den rows.

添加的行号为:3rd Party.ListRow,并包含一份财产Items,由我指定一个阵列。 阵列的数值在代表栏中显示,但并未在增加的栏目中显示。 我只收到以下案文:3rd Party.ListRow,因为ToString()被列入名单。

因此:我怎么能把新栏(如指数5)显示为<代码>ListRow.Items[5]而不是ListRow.ToString(? 我想这样说,现有各栏似乎不明确提到的所有财产。 我将如何制定<代码>Data MemberBled,以实现测绘到<代码>。 ListRow.Items[5]?

最佳回答

如果一栏有<代码>Display MembersBled或CellTemplate,则对电网中的每一项目都采用记号并估价值作为电池内容。

例如,如果你有这样的等级:

public class Person
{
    public string FirstName { get; set; }

    public string LastName { get; set; }

    public override string ToString()
    {
        return LastName;
    }
}

如果将<代码>Person的收集与电网的观点联系起来:

var people =
    new List<Person>
    {
        new Person { FirstName = "Peter", LastName = "Smith" }, 
        new Person { FirstName = "Steve", LastName = "White" },
        new Person { FirstName = "Dave", LastName = "Gates" },
    };

listView1.ItemsSource = people;

如果你创设了一个没有约束力的新栏,那么,最后一栏将列入该栏,因为压倒性<代码>ToString(<>/code> 回归代码>。 如果您改动<代码>ToString ,返回FirstName,则新的一栏将显示FirstName

我希望我正确理解你的问题。

<><>>

If you add many new columns and don t use DisplayMemberBinding then all the new columns will evaluate and show ToString() result. You need to set DisplayMemberBinding to show particular property.

var newColumn = new GridViewColumn();
newColumn.Header = "Test";
newColumn.DisplayMemberBinding = new Binding("FirstName");
gridView.Columns.Add(newColumn);

<><>> Answers to your questions:

When ToString() is called on every item (which represents a row), how is that mapped towards the columns of the GridView? How must I alter an item in the row so that the new column is filled?

除非你具体说明具有约束力的或模板,否则在提供手机提供器时,就应当进行设计,因为模板最终也将具有约束力。 你们不能改变控制电网中其代表性的立项,除非你凌驾于电线上或受电线约束的财产。

我不敢完全理解你的问题。 你们正在增加一个新的一栏,正确吗? 为什么你在你的一栏上不给人显示财产? 如果你这样做,你将能够在你想要的栏目中显示。

<><>>

我认为,我回答了你们的问题: 我认为,我已经赢得了oun。

However, here is the answer to your next question:

我将如何确定数据成员,以便绘制名单。 项目[5]?

答案:

newColumn.DisplayMemberBinding = new Binding("Items[5]");
问题回答

这是因为该清单中每个项目的托克办法被称作。 如果继承类型不能推翻,则反对。 ToString()将物体的类型名称归来。

还有一个问题,即贵国名单赢得变革,因此,国联不知道数据的变化,需要更新。





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签