I wanted to know how to trigger an event when the value i get is compared with an array & if the value is not within that array only then trigger an event.
Like i have a datagridview & i am using cell click event of it. If cell click is equal to some index then one event occurs, if that cell click value is other than the contents of the array only then an event has to trigger. How to approach this type of condition?
The code for datagridview cell click event is given below:
private void dgv_CellClick(object sender, DataGridViewCellEventArgs e)
{
if (BSView1.Rows[0].Cells[0].Value != null)
{
if (e.RowIndex >= 0)
{
for (int i = 0; i < fieldindex1.Count; i++)
{
if (Convert.ToInt16(fieldindex1[i]) == dgv1.CurrentCell.RowIndex)
{
HeaterTimer.Start();
}
else if(Convert.ToInt16(fieldindex1[i]) != dgv1.CurrentCell.RowIndex)
{
HeaterTimer.Stop();
}
}
}
}
Here if in fieldindex array has 2 values like fieldindex1={2,5} & if dgv1.CurrentCell.RowIndex is 0 1st if condition will be satisfied & during the 2nd iteration it becomes false & the timer stops. I want it to stop only if the dgv1.CurrentCell.RowIndex value is other than the fieldindex array. Also the fieldindex array is filled with only values & no zeros are present. Its a dynamic array its size increases with the value that is added to it.
Like i have a datagridview & i am using cell click event of it. If cell click is equal to some index then one event occurs, if that cell click value is other than the contents of the array only then an event has to trigger. How to approach this type of condition?
The code for datagridview cell click event is given below:
private void dgv_CellClick(object sender, DataGridViewCellEventArgs e)
{
if (BSView1.Rows[0].Cells[0].Value != null)
{
if (e.RowIndex >= 0)
{
for (int i = 0; i < fieldindex1.Count; i++)
{
if (Convert.ToInt16(fieldindex1[i]) == dgv1.CurrentCell.RowIndex)
{
HeaterTimer.Start();
}
else if(Convert.ToInt16(fieldindex1[i]) != dgv1.CurrentCell.RowIndex)
{
HeaterTimer.Stop();
}
}
}
}
Here if in fieldindex array has 2 values like fieldindex1={2,5} & if dgv1.CurrentCell.RowIndex is 0 1st if condition will be satisfied & during the 2nd iteration it becomes false & the timer stops. I want it to stop only if the dgv1.CurrentCell.RowIndex value is other than the fieldindex array. Also the fieldindex array is filled with only values & no zeros are present. Its a dynamic array its size increases with the value that is added to it.