Ich entwickle eine Windows Forms-Anwendung, die verwendet eine DataGridView
Kontrolle. Diese DataGridView
hat eine Zelle, die eine Schaltfläche enthält. Der Text Standardschaltfläche ist Start
aber wenn ich versuche, es dynamisch zu ändern mag:Stackoverflow beim Wechsel DataGridViewButtonCell Wert
((DataGridViewButtonCell)Myrow.Cells[9]).Value = "End";
oder einfach wie
Myrow.Cells[9].Value = "End";
Es wirft Ausnahme folgende:
An unhandled exception of type 'System.StackOverflowException' occurred in System.Windows.Forms.dll
Mein vollständiger Code ist wie dies:
void HighlightOnlineUsers()
{
foreach (DataGridViewRow Myrow in dataGridView1.Rows)
{
if (Convert.ToInt32(Myrow.Cells[8].Value) > 0)
{
Myrow.DefaultCellStyle.BackColor = Color.GreenYellow;
Myrow.Cells[9].Value = "End";
}
else {
Myrow.DefaultCellStyle.BackColor = Color.White;
((DataGridViewButtonCell)Myrow.Cells["SessionAction"]).Value = "Start";
}
}
}
Die Frage ist, wo nennst du 'HighlightOnlineUsers' von –
@IvanStoev es ist in der Codedatei des' Form', in dem 'Datagridview 'ist gelegen. –
Ich meine, sieht aus wie Sie es von einem Ereignis aufrufen, und die Implementierung löst das gleiche Ereignis, daher Stackoverflow. –