C# WINFORM项目中使用XPTable控件(XPTable控件使用说明一)

XPTABLE github  

GitHub - schoetbi/XPTable: sourceforge.net XPTable clone with my patches

我从MFC开始就一直使用ListView控件,直到前不久开发“汽车保养里程碑”工具才找到XPTable,用起来很方便的一个数据表展示控件,可惜网上说明不多,我来加一篇吧。

XPTable 包含三个组件:

XPTable has three main components:
 

  • Table
  • ColumnModel - the collection of Columns displayed in the Table
  • TableModel - the collection of Rows and Cells that contain the data displayed in the Table

在VS2019中从NuGet获取XPTable控件:

把三个组件拖到界面上

 在table属性中把column和model都关联上。

 控件也可以动态创建,比如下面代码:

// create a new Table, ColumnModel and TableModel
Table table = new Table();
ColumnModel columnModel = new ColumnModel();
TableModel tableModel = new TableModel();
 
// set the Table's ColumModel and TableModel
table.ColumnModel = columnModel;
table.TableModel = tableModel;
 
// add some Columns to the ColumnModel
columnModel.Columns.Add(new TextColumn("Text"));
columnModel.Columns.Add(new CheckBoxColumn("CheckBox"));
columnModel.Columns.Add(new ButtonColumn("Button"));
 
// add some Rows and Cells to the TableModel
tableModel.Rows.Add(new Row());
tableModel.Rows[0].Cells.Add(new Cell("Text 1"));
tableModel.Rows[0].Cells.Add(new Cell("CheckBox 1", true));
tableModel.Rows[0].Cells.Add(nnewew Cell("Button 1"));
tableModel.Rows.Add(new Row());
tableModel.Rows[1].Cells.Add(new Cell("Text 2"));
tableModel.Rows[1].Cells.Add(new Cell("CheckBox 2", false));
tableModel.Rows[1].Cells.Add(new Cell("Button 2"));

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

刘欣的博客

你将成为第一个打赏博主的人!

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值