如何在
dataGridView
控件中可视化城市名称?
网格
public void UpdateGrid()
{
List<Counterparty> counterparties = counterpartyController.GetAllCounterparties();
dGVCounterparties.DataSource = counterparties;
dGVCounterparties.ReadOnly = true;
dGVCounterparties.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
}
我尝试修复它,但我做不到。
您必须告诉 dataGrindView 列的属性。比如:
dGVCounterparties.Columns[0].DataPropertyName = "CityName";
您可以尝试 AutoGenerateColumns 标志。
dGVCounterparties.AutoGenerateColumns = true;