我试图在 DataGridView 中格式化 2 列的单元格,但在 UI 上你看不到格式。这是我的代码:
gridView.Rows.Clear();
gridView.Columns.Clear();
List<DataGridViewColumn> rowList = new List<DataGridViewColumn>();
DataGridViewColumn col;
foreach (PropertyInfo info in typeof(T).GetProperties())
{
col = new DataGridViewTextBoxColumn();
col.Name = GetNameAttribute(info);
col.HeaderText = GetTextAttribute(info);
if (GetFieldTypeAttribute(info) == MyFieldTypes.MoneyField)
{
col.DefaultCellStyle = new DataGridViewCellStyle() { Format = "C2", Alignment = DataGridViewContentAlignment.MiddleRight };
col.ValueType = typeof(System.Double);
}
gridView.Columns.Add(col);
}
gridView.Refresh();
也许你可以帮助我?
暮色呼如
相关分类