पूरे DataGrid
के रंग को एक बार में बदलने के बजाय, आपको इसे CellFormatting
ईवेंट ओवरराइड करके प्रतिपादन का प्रबंधन करना चाहिए। पंक्तियों को केवल तभी चित्रित किया जाएगा जब वे वास्तव में स्क्रीन पर प्रदर्शित होते हैं।
private void aufgabenDataGridView_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{
DataGridViewRow row = aufgabenDataGridView.Rows[e.RowIndex];
AufgabeStatus status = (AufgabeStatus) Enum.Parse(typeof(AufgabeStatus), (string) row.Cells["StatusColumn"].Value);
switch (status)
{
case (AufgabeStatus.NotStarted):
e.CellStyle.BackColor = Color.LightCyan;
break;
case (AufgabeStatus.InProgress):
e.CellStyle.BackColor = Color.LemonChiffon;
break;
case (AufgabeStatus.Completed):
e.CellStyle.BackColor = Color.PaleGreen;
break;
case (AufgabeStatus.Deferred):
e.CellStyle.BackColor = Color.LightPink;
break;
default:
e.CellStyle.BackColor = Color.White;
break;
}
}
यह अभी भी बहुत धीमी है, तो वास्तविक वस्तु पंक्ति के लिए बाध्य है हो रही है कोशिश:
...
DataGridViewRow row = aufgabenDataGridView.Rows[e.RowIndex];
var aufgabe = (Aufgabe) row.DataBoundItem;
AufgabeStatus status = aufgabe.Status;
...
स्रोत
2009-10-27 11:48:15
तुम्हारा मतलब है यह प्रति पंक्ति 100 - 200ms लेता है? यह बहुत भारी लगता है। – leppie
कितने पंक्तियां? क्या आपके पास फॉर्म पर डबल-बफरिंग सेट है? क्या आपने सेलफॉर्मेटिंग ईवेंट का उपयोग करने का प्रयास किया है? – stuartd