目前我正在使用 C# datagridview 来绘制包含 >500 行和 >700 列的晶圆图。
但是,有几个问题:
性能缓慢。由于我需要调整列宽,我必须循环并单独分配。
for (int i = 0; i < this.dgvCompleteMapGrid.Columns.Count; i++) { this.dgvCompleteMapGrid.Columns[i].Width = 8; }
我只需要为具有值的单元格绘制单元格边界,因为晶圆图几乎是圆形的。我正在使用 cellpainting 事件:
if (e.Value != null) { if (e.Value.ToString() == "") { e.AdvancedBorderStyle.All = DataGridViewAdvancedCellBorderStyle.None; } else { if (e.Value.ToString() == "1") { e.CellStyle.BackColor = Color.Lime; } else { e.CellStyle.BackColor = Color.Red; } //check if the top border set None for neighbor empty value cell if (e.AdvancedBorderStyle.Top.ToString() == "None") { e.AdvancedBorderStyle.Top = DataGridViewAdvancedCellBorderStyle.Single; } //repeat the same for left right and bottom } }
但是,它似乎会为大多数单元格绘制多个边框副本。
是否推荐使用 Datagridview?我试图在面板上绘制矩形,性能更差。