0
當列表綁定到DataGridView時,是否有方法從數組屬性顯示格式化的字符串?從DataGridView中的數組顯示格式化的字符串DataSource
我目前使用下面的代碼:
var bindingList = new BindingList<Stage>(stageList);
var source = new BindingSource(bindingList, null);
dv.DataSource = source;
dv.AutoGenerateColumns = true;
internal class Stage
{
.
public bool isNew {get; protected internal set; }
public int Id { get; protected internal set; }
public short[] Level { get; protected internal set; } = new short[4];
.
.
}
無論是「是否新款」和「ID」屬性顯示正常。 我希望得到下面的示例輸出:
IsNew | Id | Stage
[✓] 1 1/5/7/9
[ ] 2 2/3/8/9
[ ] 3 3/5/8/10
,其中第一階段是格式化爲
string.Format("{0}/{1}/{2}/{3}", Stage[0], Stage[1], Stage[2], Stage[3]);
你可以使用CellFormatting或公開只返回格式化數據的只讀屬性 – Plutonix