如何在dataGridView中可视化数据模型?

问题描述 投票:0回答:1

如何在

dataGridView
控件中可视化城市名称?

网格

Grid image

public void UpdateGrid()
{
  List<Counterparty> counterparties = counterpartyController.GetAllCounterparties();
  dGVCounterparties.DataSource = counterparties;
  dGVCounterparties.ReadOnly = true;
  dGVCounterparties.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
}

我尝试修复它,但我做不到。

c# database entity-framework
1个回答
0
投票

您必须告诉 dataGrindView 列的属性。比如:

dGVCounterparties.Columns[0].DataPropertyName = "CityName";

您可以尝试 AutoGenerateColumns 标志。

dGVCounterparties.AutoGenerateColumns = true;
© www.soinside.com 2019 - 2024. All rights reserved.