The IF statement, in For Loop, in C#

    Good morning!
    I have a problem in C#, with the IF statement, in For Loop.
    I want to take the IF statement in For Loop statement; for hide the columns wich contain false value, end show the true columns only, in DataGridView.
    thank you.

    public void showClassRoomCourses()
                VisibleDatGridView();// Show the DatGridView.
                int[] semestersClassIndex = new int[1];                
                int[] semestersCourseIndex = new int[37];
                string[] semestersColumnValue = new string[1];               
                string[] semestersClassesNames = {"Class01", "Class02", "Class1", "Class2", "Class3", "Class4",
                        "Class5", "Class6", "Class7", "Class8", "Class9", "Class10", "Class11", "Class12"};
                semestersClassIndex[0] = classComboBox2.SelectedIndex;
                MessageBox.Show("قبل اختيار الصف" + semestersClassIndex[0].ToString());//For Test Value only                
                this.firstSemesterTableAdapter.FillByFirstSemesterClassId(this.studentsGradesDataSet.FirstSemester, (semestersClassIndex[0] + 1));
                MessageBox.Show("بعد اختيار الصف" + semestersClassIndex[0].ToString()); //For Test Value only
                for (int i = 0; i < 37; i++) // the courses (Lessons) count is 37
                    MessageBox.Show("رقم المادة داخل الحلقة" + i.ToString()); //For Test Value only                   
                    //string columnValue = studentsGradesDataSet.Tables["CoursesCheckState"].Rows[i]["Class01"].ToString();
                    semestersColumnValue[0] = studentsGradesDataSet.Tables["CoursesCheckState"].Rows[i][semestersClassesNames[semestersClassIndex[0]]].ToString();                 
                    MessageBox.Show("رقم المادة بعد اختيار الحقل" + i.ToString()); //For Test Value only
                    MessageBox.Show("قبل إخفاء حقول جدول العرض، الحقل يساوي:" + semestersColumnValue[0]); //For Test Value only
                    // The proble is here!
                    // it reject the If condition!
                    if (semestersColumnValue[0] == "false")
                    {   // Hide the false columns
                        MessageBox.Show("في الإجراء داخل الشرط، وقبل إخفاء جدول العرض" + semestersColumnValue[0]); //For Test Value only
                        firstSemesterDataGridView.Columns[semestersCourseIndex[i]].Visible = false;// هذا ينجح قبل إظهار جدول العرض وبعده
                        //firstSemesterDataGridView.Columns["Coran"].Visible = false;//هذا ينجح بعد إظهار جدول العرض فقط
                        MessageBox.Show("في الإجراء داخل الشرط، بعد إخفاء جدول العرض" + semestersColumnValue[0]); //For Test Value only
                // حذف المصفوفات
                // Delet Arrays
                semestersClassIndex = null;
                semestersCourseIndex = null;
                semestersClassesNames = null;               
            catch (System.Exception ex)
    Abubakar Jallo Asked on August 16, 2015 in No Category.

    This question was posted in Stack Exchange

    and what is the problem?

    on August 16, 2015.

    debug your application and check the value of `semestersColumnValue[0]`

    on August 16, 2015.
    Add Comment
  • 0 Answer(s)

    Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.