DataGridView Dgv绑定数据源DataTable dt;
Dgv.DataSource = dt;怎么设置DataGridView 显示
dt.Rows[0]["FieldName"]
Dgv.Rows[0].Cells["FieldName"] 值的别名?比如说 dt.Rows[0]["FieldName"]的值是人员编号,通过查询数据库获得对应的人员名称,显示为人员名称。但在
Dgv.Rows[0].Cells["FieldName"].Value 时获取的还是人员编号。熟悉Dephi的知道,可以通过TDataSet 的OnGetText事件 设置 字段的Text 来实现。C#中怎么实现,应该在什么事件中设置??
Dgv.DataSource = dt;怎么设置DataGridView 显示
dt.Rows[0]["FieldName"]
Dgv.Rows[0].Cells["FieldName"] 值的别名?比如说 dt.Rows[0]["FieldName"]的值是人员编号,通过查询数据库获得对应的人员名称,显示为人员名称。但在
Dgv.Rows[0].Cells["FieldName"].Value 时获取的还是人员编号。熟悉Dephi的知道,可以通过TDataSet 的OnGetText事件 设置 字段的Text 来实现。C#中怎么实现,应该在什么事件中设置??
2,DataGridView 设置表头text
不是要设置 列的别名,而是 单元格数据的别名,比如column["FieldName"] 中本是人员编号,怎么让显示为人员名称。但是在dt.Rows[0]["FieldName"] 时获取的还是人员编号。
{
if (e.ColumnIndex==2 && e.Value is int)
{
int i= (int)e.Value;
e.Value = "";
}
}