如何在Eto表格GridView中创建数字列(理想情况下为整数)?
以下是我的两个字符串列的代码
stats.Columns.Add(new GridColumn
{
DataCell = new TextBoxCell { Binding = Binding.Property<RulesDocAdapter, string>(r => r.Name) },
HeaderText = "Name"
});
stats.Columns.Add(new GridColumn
{
DataCell = new TextBoxCell { Binding = Binding.Property<RulesDocAdapter, string>(r => r.Abbreviation) },
HeaderText = "Abbreviation"
});
答案 0 :(得分:1)
要使用不同的列,可以使用属性绑定上的Convert()扩展名将integer属性转换为字符串,如下所示:
Binding.Property((RulesDocAdapter r) => r.IntProperty).Convert(v => v.ToString(), s => { int i = 0; return int.TryParse(s, out i) ? i : -1; })