public void Allarm(string DateTime, string Number, string Message) { if (this.dataGridView1.InvokeRequired) { SetNewAllarm stc = new SetNewAllarm(Allarm); this.Invoke(stc, new object[] { DateTime, Number, Message }); } else { smartrack pp = mainFrm.searchDevice(Number); dataGridView1.Rows.Add(); if (pp != null) { DataGridViewImageCell displayCell = null; displayCell = (DataGridViewImageCell)dataGridView1.Rows[dataGridView1.RowCount - 1].Cells[0]; displayCell.Value = Image.FromFile(pp.image); dataGridView1.Rows[dataGridView1.RowCount - 1].Cells[1].Value = DateTime; dataGridView1.Rows[dataGridView1.RowCount - 1].Cells[2].Value = pp.Description + " (" + Number + ")"; dataGridView1.Rows[dataGridView1.RowCount - 1].Cells[3].Value = Message; } else { dataGridView1.Rows[dataGridView1.RowCount - 1].Cells[1].Value = DateTime; dataGridView1.Rows[dataGridView1.RowCount - 1].Cells[2].Value = "(" + Number + ")"; dataGridView1.Rows[dataGridView1.RowCount - 1].Cells[3].Value = Message; } } }
public void Allarm(string DateTime,string Number,string Message) { if (this.log.InvokeRequired) { SetNewAllarm stc = new SetNewAllarm(Allarm); this.Invoke(stc, new object[] { DateTime,Number,Message }); } else { frmAllarm.addNewAllarm(DateTime, Number, Message); } }