CHECKBOX对条件适用可见TRUE [英] CHECKBOX Visible TRUE For Condition Apply

查看:101
本文介绍了CHECKBOX对条件适用可见TRUE的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨..所有



这里我使用代码进行数据匹配意味着CHECKBOX是可见真的..我需要任何其他选项..请告诉我你的建议< br $> b $ b



Hi.. All

Here i Use Code For Data Match means CHECKBOX is Visible True.. I need any other Option.. Please Tell me Your advice


Dim strSQL10 As String = "SELECT * FROM PeriodDetails where Class = '" & List_Class_SA.Text & "' and Section='" & List_Section_SA.Text & "' and Day = '" & CDate(DTP1_SA.Value) & "'"
        Me.DaAp10 = New SqlDataAdapter(strSQL10, con)
        Dim Dset10 As New DataSet
        DaAp10.Fill(Dset10, "PeriodDetails")

        For i As Integer = 0 To Dset10.Tables(0).Rows.Count - 1
            txtPeriodDisplay.Text = Dset10.Tables(0).Rows(i).Item("Period")
        Next i










If txtPeriodDisplay.Text = "1" Then
            CB1.Visible = True
            CB2.Visible = False
            CB3.Visible = False
            CB4.Visible = False
            CB5.Visible = False
            txtPeriodDisplay.Text = ""

        ElseIf txtPeriodDisplay.Text = "2" Then
            CB1.Visible = True
            CB2.Visible = True
            CB3.Visible = False
            CB4.Visible = False
            CB5.Visible = False
            txtPeriodDisplay.Text = ""

        ElseIf txtPeriodDisplay.Text = "3" Then
            CB1.Visible = True
            CB2.Visible = True
            CB3.Visible = True
            CB4.Visible = False
            CB5.Visible = False
            txtPeriodDisplay.Text = ""

        ElseIf txtPeriodDisplay.Text = "4" Then
            CB1.Visible = True
            CB2.Visible = True
            CB3.Visible = True
            CB4.Visible = True
            CB5.Visible = False
            txtPeriodDisplay.Text = ""

        ElseIf txtPeriodDisplay.Text = "5" Then
            CB1.Visible = True
            CB2.Visible = True
            CB3.Visible = True
            CB4.Visible = True
            CB5.Visible = True
            txtPeriodDisplay.Text = ""
        Else

            CB1.Visible = False
            CB2.Visible = False
            CB3.Visible = False
            CB4.Visible = False
            CB5.Visible = False
        End If

推荐答案

Do它循环:

Do it in a loop:
Dim i As Integer  = 0, j As Integer = 0

j  = Int32.TryParse(Me.txtPeriodDisplay.Text)

For i = 1 to j
    'here change visibility
Next i


checkbox visible属性需要一个布尔值。任何布尔值。

txtPeriodDisplay.Text =1是一个布尔值。因此你可以这样做:



The checkbox visible property wants a boolean value. ANY boolean value.
txtPeriodDisplay.Text = "1" is a boolean value. Therefore you can do this:

CB1.Visible = txtPeriodDisplay.Text = "1"
CB2.Visible = txtPeriodDisplay.Text = "2"
CB3.Visible = txtPeriodDisplay.Text = "3"
CB4.Visible = txtPeriodDisplay.Text = "4"
CB5.Visible = txtPeriodDisplay.Text = "5"





它应该有相同的结果。





****************更新****************

糟糕,我没有'请注意,如果文本框中有2,CB1也依赖...你可以这样做:



And it should have the same result.


**************** Update ****************
Oops, I didn''t notice that CB1 also relied on if "2" was in the textbox...you can do something like this:

CB1.Visible = (txtPeriodDisplay.Text = "1" OrElse txtPeriodDisplayl.Text = "2")





所以你可以为每个有效的案例继续添加OrElse。



************** **更新****************

Oka y,这个怎么样?



So you can just keep adding OrElse for each case that is valid.

**************** Update ****************
Okay, How about this one?

CB1.Visible = txtPeriodDisplay.Text.Length > 0 AndAlso CInt(txtPeriodDisplay.Text) >= 1
CB2.Visible = txtPeriodDisplay.Text.Length > 0 AndAlso CInt(txtPeriodDisplay.Text) >= 2
CB3.Visible = txtPeriodDisplay.Text.Length > 0 AndAlso CInt(txtPeriodDisplay.Text) >= 3
CB4.Visible = txtPeriodDisplay.Text.Length > 0 AndAlso CInt(txtPeriodDisplay.Text) >= 4
CB5.Visible = txtPeriodDisplay.Text.Length > 0 AndAlso CInt(txtPeriodDisplay.Text) >= 5


这篇关于CHECKBOX对条件适用可见TRUE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆