WinForms DataGridView 綁定數據源後,只有點擊選中某行時該行數據才可見,未選中時行內容空白。

DefaultCellStyle.ForeColor、RowsDefaultCellStyle.ForeColor、AlternatingRowsDefaultCellStyle.ForeColor 是否為 Color.White 或與背景色一致。改為 Color.Black 即可。DataSource 綁定的是包含數據的集合,且屬性名與列 DataPropertyName 匹配。CellPainting 或 RowPrePaint,檢查是否誤將文本繪製為透明或跳過繪製。// 檢查樣式屬性
dataGridView1.DefaultCellStyle.ForeColor = Color.Black;
dataGridView1.RowsDefaultCellStyle.ForeColor = Color.Black;
dataGridView1.AlternatingRowsDefaultCellStyle.ForeColor = Color.Black;
// 若問題依舊,提供綁定代碼片段進一步分析
90% 此類問題為字體顏色誤設置導致,優先排查樣式屬性。