Technical guru

Technical guru

  • NA
  • 63
  • 8.6k

use for loop with if else in C#

Oct 7 2018 4:46 AM
use for loop with if else in C#
this is my code 
private void grid1_RowColChange(object Sender, FlexCell.Grid.RowColChangeEventArgs e)
{
if (e.Col >= 3 && e.Row >= 2)
{
if (e.Col % 2 != 0)
{
for (int i = 2; i <= 40; i = i + 2)
{
if (grid1.Cell(i, 1).Text == "BRECK")
{
frmTeacherList frmt = new frmTeacherList(this);
frmt.Visible = false;
break;
}
else
{
frmTeacherList frmt = new frmTeacherList(this);
frmt.Show();
}
}
}
else if (e.Col % 2 == 0)
{
for (int i = 2; i <= 40; i = i + 2)
{
if (grid1.Cell(i, 1).Text == "BRECK")
{
frmsubject frm = new frmsubject(this);
frm.Visible = false;
break;
}
else
{
frmsubject frm = new frmsubject(this);
frm.CmbClass.Text = cmbClass.Text;
frm.cmbSection.Text = cmbSection.Text;
frm.Show();
}
}
}
}
 
 But there Executed (open)frmSubject and frmTeacher also through loop 
 
 
 Please Help

Answers (2)