Groups | Blog | Home
all groups > vb.net controls > january 2005 >

vb.net controls : Checkbox changed


Ken Tucker [MVP]
1/12/2005 9:07:12 AM
Hi,

Write code in the checkboxes checkedchange event to enable or
disable the other checkboxes.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwindowsformscheckboxclasscheckedchangedtopic.asp

Ken
-----------------
[quoted text, click to view]
Hello,

I'm working in VB.net and want to take actions after someone selected one
of the checkbox items.

I've 2 checkboxes, and some fiedls that are disabled. If a person select
checkbox 1 some of the other fields should be enabled. If the user select
checkbox 2, other fields should be enabled.

The two checkboxes are grouped.

Thanks for the help,

Regards,

Edward

Edward van Nijmweegen
1/12/2005 1:36:11 PM
Hello,

I'm working in VB.net and want to take actions after someone selected one
of the checkbox items.

I've 2 checkboxes, and some fiedls that are disabled. If a person select
checkbox 1 some of the other fields should be enabled. If the user select
checkbox 2, other fields should be enabled.

The two checkboxes are grouped.

Thanks for the help,

Regards,

Edward van Nijmweegen
1/12/2005 3:33:03 PM
Hi Ken,

I've tried that, but it didn't work. Here is my code:
Private Sub txtProductgrp_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
txtProductgrp.SelectedIndexChanged

Dim i As Integer
Dim selected As Integer
selected = 0
For i = 0 To (txtProductgrp.Items.Count() - 1)
If txtProductgrp.Items(i).Selected = True Then
selected = 1
End If
Next
If selected = 1 Then
txtSubject.Enabled = True
txtProduct1.enabled = True
Else
txtSubject.Enabled = False
txtProduct1.enabled = False
End If
End Sub

There are only 2 checkboxes, you can select them both or just one, but at
least if one of them is selected people should be able to modify txtSubject
and txtProduct1.

Thanks for you reply.

Regards,

Edward


Op Wed, 12 Jan 2005 09:07:12 -0500 schreef Ken Tucker [MVP]:

[quoted text, click to view]


--
Herfried K. Wagner [MVP]
1/12/2005 3:56:20 PM
"Edward van Nijmweegen" <e_van_nijmweegen@hotmail.com> schrieb:
[quoted text, click to view]

As Ken said, read the documentation for the checkboxs' *'CheckedChanged'*
event!

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
AddThis Social Bookmark Button