110,536
社区成员
发帖
与我相关
我的任务
分享
public static readonly Dictionary<int, string> DictDisplay = new Dictionary<int, string>(6)
{
{ 0, "删除" },
{ 1, "屏蔽" },
{ 2, "显示" }
};
var result = DictDisplay.GroupJoin(Model.Context.Tests,
i=>i.Key,
o=>o.Display,
(i, os) => os.DefaultIfEmpty().Select(r => new
{
id = r.ID,
name = r.Name,
display = i.Value
})).SelectMany(m => m);
private void gvinfo_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{
if (e.ColumnIndex == 2) //哪一列
{
e.Value = Sys.DictDisplay[(int)e.Value];
}
}
private void dataGridView1_RowsAdded(object sender, DataGridViewRowsAddedEventArgs e)
{
int i = 0;
if (int.TryParse(dataGridView1.Rows[e.RowIndex].Cells[2].Value.ToString(), out i))
{
dataGridView1.Rows[e.RowIndex].Cells[2].Value = DictDisplay[i];
}
}