gpt4 book ai didi

c# - 以编程方式将列添加到 WPF 中的 ListView ?

转载 作者:可可西里 更新时间:2023-11-01 08:02:03 25 4
gpt4 key购买 nike

如何以编程方式将列添加到 ListView ?

最佳答案

这样设置 listView.View:

GridView myGridView = new GridView();
myGridView.AllowsColumnReorder = true;
myGridView.ColumnHeaderToolTip = "Employee Information";

GridViewColumn gvc1 = new GridViewColumn();
gvc1.DisplayMemberBinding = new Binding("FirstName");
gvc1.Header = "FirstName";
gvc1.Width = 100;
myGridView.Columns.Add(gvc1);
GridViewColumn gvc2 = new GridViewColumn();
gvc2.DisplayMemberBinding = new Binding("LastName");
gvc2.Header = "Last Name";
gvc2.Width = 100;
myGridView.Columns.Add(gvc2);
GridViewColumn gvc3 = new GridViewColumn();
gvc3.DisplayMemberBinding = new Binding("EmployeeNumber");
gvc3.Header = "Employee No.";
gvc3.Width = 100;
myGridView.Columns.Add(gvc3);

listView.View = myGridView;

关于c# - 以编程方式将列添加到 WPF 中的 ListView ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/868204/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com