Click here to Skip to main content
15,895,142 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
Hi.. All

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


VB
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



VB
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
Posted
Updated 6-Mar-13 3:13am
v2
Comments
ZurdoDev 6-Mar-13 9:10am    
What exactly is your question?
Navas Khanj 6-Mar-13 9:13am    
Table Data and Condition Data is Match means I want to CheckBox Visible is True
okishore7 6-Mar-13 9:14am    
better go to switch case
Orcun Iyigun 6-Mar-13 9:24am    
Do you have any reason why? What is the difference?

Do it in a loop:
VB
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
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 6-Mar-13 18:05pm    
Fair enough, for such a question, a 5.
—SA
Maciej Los 7-Mar-13 1:32am    
Thank you, Sergey ;)
Sergey Alexandrovich Kryukov 6-Mar-13 18:10pm    
Maciej,

Sorry, I somehow missed your question about progress update while downloading, I'll quickly answer here, okay?
Please see my past answer:
http://www.codeproject.com/Answers/143488/how-to-download-a-file-from-internet#answer1
As the code is a loop, essentially, it can be use anywhere. You don't have to find out and handle any mysterious events, can invoke whatever you want from inside the loop. The downloading with UI should of course be done in a separate thread. That's all...

(Navas, sorry for off-topic.)

—SA
Maciej Los 7-Mar-13 2:15am    
Sergey,

I've send you an e-mail.

Thank You Very Much!
Sergey Alexandrovich Kryukov 7-Mar-13 2:21am    
Sure.
—SA
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"


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:
VB
CB1.Visible = (txtPeriodDisplay.Text = "1" OrElse txtPeriodDisplayl.Text = "2")


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

**************** Update ****************
Okay, How about this one?
VB
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
 
Share this answer
 
v3
Comments
Maciej Los 6-Mar-13 11:42am    
Nice, +5!
Navas Khanj 6-Mar-13 11:43am    
nice.. but i want (txtPeriodDisplay.Text = "2") means want to CB1 and CB2 Want Display.Please tell me any idea.
Kschuler 6-Mar-13 11:53am    
I updated my solution. All you need to do is add OrElses for each case that makes that checkbox visible.
Navas Khanj 6-Mar-13 14:06pm    
hi.
What I need..
txtPeriodDisplay.Text = "2" means i want Display CB1 and CB2
txtPeriodDisplay.Text = "5" means i want Display CB1,CB2,CB3,CB4,CB5
But u Code is working txtPeriodDisplay.Text = "2" means CB2 only Display..Please tell me how i do..
Kschuler 6-Mar-13 14:21pm    
I know I didn't give you a complete answer with my second solution, but I gave you the tools to figure it out for yourself. You can use the method I started and just expand on it for each checkbox. I've also posted a third option if you want a shorter solution. It assumes that you will always have either an empty string or a numeric value inside txtPeriodDisplay.Text.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900