jeudi 15 octobre 2020

Checkbox bidimensional array does not working

I want to create a bidimensional array to plot checkboxes in rows and cols. Nevertheless, this line is not working: CheckB_Well(rows_C1, cols_C1).Location = New Point(40 + 50 * cols_C1, 20 + 25 * (well_rows - 1 - rows_C1))

The checkboxes are not shown in the location defined.

Sub Check_Panel()
    Me.GroupBox3.Controls.Clear()
    Dim CheckB_Well(,)
    Dim rows_C1 As Integer
    Dim cols_C1 As Integer

    If Opt6.Checked = True Then
        well_number = 6
        well_rows = 2
        well_cols = 3
    ElseIf Opt12.Checked = True Then
        well_number = 12
        well_rows = 3
        well_cols = 4
    ElseIf Opt24.Checked = True Then
        well_number = 24
        well_rows = 4
        well_cols = 6
    End If

    ReDim CheckB_Well(well_rows - 1, well_cols - 1)

    For rows_C1 = 0 To well_rows - 1
        For cols_C1 = 0 To well_cols - 1
            CheckB_Well(rows_C1, cols_C1) = New CheckBox
            CheckB_Well(rows_C1, cols_C1).Name = "Well" + Str(rows_C1) + ";" + Str(cols_C1)
            CheckB_Well(rows_C1, cols_C1).Text = Str(rows_C1) + ";" + Str(cols_C1)
            CheckB_Well(rows_C1, cols_C1).Visible = True
            If rows_C1 Mod 2 = 0 Then
                CheckB_Well(rows_C1, cols_C1).Location = New Point(40 + 50 * cols_C1, 20 + 25 * (well_rows - 1 - rows_C1))
            Else
                CheckB_Well(rows_C1, cols_C1).Location = New Point(40 + 50 * (well_cols - 1 - cols_C1), 20 + 25 * (well_rows - 1 - rows_C1))
            End If
            Me.GroupBox3.Controls.Add(CheckB_Well(rows_C1, cols_C1))
        Next cols_C1
    Next rows_C1
End Sub



Aucun commentaire:

Enregistrer un commentaire