【发布时间】:2021-05-03 19:14:32
【问题描述】:
我正在编写 ID3 标记编辑器,并且那里有 DataGridView。我有 ID3 帧 ID(“TIT1”、“TIT2”等),我想显示相应的标签而不是它们(“Title 1”、“Title 2”等)... 所以我使用了 CellFormatting,但我注意到这样的事件被调用的次数比我真正需要的要多得多,这让我的程序变慢了。有没有更好的方法来实现它?我需要在向 DataGridView 添加新行时格式化单元格。
private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{
if (known_frameIDs_current.Contains(e.Value))
{
e.Value = frameID_labels[Array.IndexOf(known_frameIDs_current,e.Value), isEnglish];
}
e.FormattingApplied = true;
}
【问题讨论】:
-
DataGridView有一个RowsAdded事件。 -
别找你了;你是说你有一个DGV,显示一个DataTable,其中的行写着TIT1 TIT2,你想让他们说“Title 1”,“Title 2”?使用字典并替换值..
标签: c# datatable datagridview cell datasource