Private Sub clstLinks_ItemCheck(ByVal sender As System.Object, ByVal e As ItemCheckEventArgs) Handles clstLinks.ItemCheck txt1.Visible = False txt2.Visible = False txt3.Visible = False txt4.Visible = False txt5.Visible = False txt6.Visible = False If e.CurrentValue = CheckState.Unchecked Then txt1.Visible = True Else txt1.Visible = False End If If e.NewValue = CheckState.Checked Then txt2.Visible = True Else txt2.Visible = False End If End Sub End Class
CheckedListBox making textbox visibleHaving problem making selected index from checkedlistbox turn specific
Page 1 of 1
7 Replies - 3158 Views - Last Post: 13 December 2009 - 10:58 PM
#1
CheckedListBox making textbox visible
Posted 13 December 2009 - 08:14 PM
My question to y'all is this....I have a CheckedListBox with 6 different indices that all correspond to a textBox. For example: Index 0 corresponds with TextBox1, Index 1 corresponds with TextBox2, and so forth. When the user selects the item in the CheckedListBox, the TextBox with that particular index becomes visible. I am at a loss. I have been working on this for 4 days now, with no end in sight! Thank y'all for your time!
Replies To: CheckedListBox making textbox visible
#2
Re: CheckedListBox making textbox visible
Posted 13 December 2009 - 08:42 PM
Make an array of textboxes:
Load event fill the array:
Then in your ItemClicked event:
Private TList() As TextBox
Load event fill the array:
TList = New TextBox() {TextBox1, TextBox2, TextBox3, TextBox4}
Then in your ItemClicked event:
If e.NewValue = CheckState.Checked Then TList(e.Index).Visible = False Else TList(e.Index).Visible = True End If
#3
Re: CheckedListBox making textbox visible
Posted 13 December 2009 - 08:56 PM
Thank you so much! I didn't think you could still do that...especially on the newer versions of VB!
Now my question to you is, is there any way to seperate it? For example if a user checks items 1, 4, 5 then the TextBoxes 1, 4, 5 should be visible. The others are hidden. Would a For...Next Statement work in this situation such as:
This is where I am totally confused! Thank you once again for your help!
Now my question to you is, is there any way to seperate it? For example if a user checks items 1, 4, 5 then the TextBoxes 1, 4, 5 should be visible. The others are hidden. Would a For...Next Statement work in this situation such as:
For Each CheckedListBox1.CheckedItemCollection Next
This is where I am totally confused! Thank you once again for your help!
#4
Re: CheckedListBox making textbox visible
Posted 13 December 2009 - 09:33 PM
Not sure what you mean my example does just that as is. ???
#5
Re: CheckedListBox making textbox visible
Posted 13 December 2009 - 09:42 PM
Here is the code I am running...
What is happening is that I am only able to return one TextBox. I cannot use the Multi-Select or Multi-Extended Property because of the CheckedListBox. We are supposed to have more than one TextBox enabled. I am not sure what to do from there.
Private Sub clstLinks_ItemCheck(ByVal sender As System.Object, ByVal e As ItemCheckEventArgs) Handles clstLinks.ItemCheck
Dim txtAll As TextBox() = New TextBox() {txt1, txt2, txt3, txt4, txt5, txt6}
clstLinks.GetItemChecked(e.Index)
If e.NewValue = CheckState.Checked Then
txtAll(e.Index).Visible = True
Else
txtAll(e.Index).Visible = False
End If
End Sub
What is happening is that I am only able to return one TextBox. I cannot use the Multi-Select or Multi-Extended Property because of the CheckedListBox. We are supposed to have more than one TextBox enabled. I am not sure what to do from there.
#6
Re: CheckedListBox making textbox visible
Posted 13 December 2009 - 09:50 PM
The problem I'm having is when I click on more than one of the check boxes, it's returning the value of the last check box. If I click on 1, 3, and 6, it returns the TextBox for item 6.
#7
Re: CheckedListBox making textbox visible
Posted 13 December 2009 - 10:04 PM
More like this:
My example uses SelectionMode/one
Public Class blah
Private TList() As TextBox
Private Sub Form1_Load(...)
TList = New TextBox() {TextBox1, TextBox2, TextBox3, TextBox4}
End Sub
Private Sub CheckedListBox1_ItemCheck(ByVal sender As Object, ByVal e As System.Windows.Forms.ItemCheckEventArgs) Handles CheckedListBox1.ItemCheck
If e.NewValue = CheckState.Checked Then
TList(e.Index).Visible = True
Else
TList(e.Index).Visible = False
End If
End Sub
End Class 'blah
My example uses SelectionMode/one
#8
Re: CheckedListBox making textbox visible
Posted 13 December 2009 - 10:58 PM
THANK YOU SO MUCH FOR YOUR GUIDANCE!!!!
I worked and worked and finally got this code to work! I don't think it's exactly what I needed to do, but IT WORKS!!! LOL
Here is my FINAL code:
Once again, HawkValley1...THANK YOU SO MUCH!!
I worked and worked and finally got this code to work! I don't think it's exactly what I needed to do, but IT WORKS!!! LOL
Here is my FINAL code:
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
txt1.Visible = False
txt2.Visible = False
txt3.Visible = False
txt4.Visible = False
txt5.Visible = False
txt6.Visible = False
End Sub
Private Sub clstLinks_ItemCheck(ByVal sender As System.Object, ByVal e As ItemCheckEventArgs) Handles clstLinks.ItemCheck
Dim txtAll() As TextBox = New TextBox() {txt1, txt2, txt3, txt4, txt5, txt6}
If e.NewValue = CheckState.Checked Then
txtAll(e.Index).Visible = True
Else
txtAll(e.Index).Visible = False
End If
End Sub
End Class
Once again, HawkValley1...THANK YOU SO MUCH!!
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote



|