blah blah blah is here! blah blah » Close

up1down
link

Guys, i hope i make sense with this question. I have a small app that will be running all the time but the form will be minimized or hidden, now i have a DataGrid1 with a status column. the datagrid refreshes every few minutes, when the word "OPEN" appears in the last row of the 'Status' column i want the form to show.

I tried somthing like the below, but that applies to every row rather than the last?

int count = 0; foreach (DataGridViewRow row in DataGridView1.Rows)
{
if (row.IsNewRow) break;
object obj = row.Cells[0].Value;
if (obj != null && !DBNull.Value.Equals(obj) && obj.ToString() == "OPEN") count++;
{
form1.show();
}
}

last answered one year ago

1 answers

link

Assuming there's a blank 'new row' in the grid and the grid is on the form which is minimized or hidden, try this:

int count = DataGridView1.Rows.Count;
if (count > 1)
{
object obj = DataGridView1.Rows[count - 2].Cells["Status"].Value;
if (obj != null && !DBNull.Value.Equals(obj) && obj.ToString() == "OPEN")
{
if (this.WindowState == FormWindowState.Minimized) this.WindowState = FormWindowState.Normal;
if (!this.Visible) this.Visible = true;
}
}

Vulpes - That's perfect Thank you works a treat...

Feedback