|
Prev: String functions vs. XML literals... speed
Next: how to make a boolean default to True in web service
From: Mark on 8 Jul 2008 12:44 I have a form which during the load event creates 1 or more checkboxes. Also, as each checkbox is added to the controls collection I also add a handler: AddHandler o.Click, AddressOf MedicationStop_Click So, all of the checkboxes use the same handler That part seems to go well. However, if a user actually checks or unchecks one or more of the boxes, I can't seem to determine which boxes are checked or their checked state. Can someone show me the error of my ways? Here is my handler.. Private Sub MedicationStop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Dim o As Control 'Need to show/hide a corresponding combobox depending on the checked state For Each o In pnlMeds.Controls If TypeOf (o) Is CheckBox Then 'How do I determine: 'A. Which combobox was clicked 'B. What is the CheckedState 'There is no o.CheckedState property! End If Next End Sub
From: Armin Zingler on 8 Jul 2008 13:11 "Mark" <Mark(a)discussions.microsoft.com> schrieb > I have a form which during the load event creates 1 or more > checkboxes. Also, as each checkbox is added to the controls > collection I also add a handler: > > AddHandler o.Click, AddressOf MedicationStop_Click Do you really want to handle thte Click event or maybe the CheckedChange event? > So, all of the checkboxes use the same handler > > That part seems to go well. However, if a user actually checks or > unchecks one or more of the boxes, I can't seem to determine which > boxes are checked or their checked state. Can someone show me the > error of my ways? Here is my handler.. > > Private Sub MedicationStop_Click(ByVal sender As System.Object, > ByVal e As System.EventArgs) 'sender' is the sender, AKA checkbox. dim chk = directcast(sender, checkbox) chk.<whatever> Armin
From: Mark on 8 Jul 2008 14:01
Perfecto! Just what I was looking for. Thanks! "Armin Zingler" wrote: > "Mark" <Mark(a)discussions.microsoft.com> schrieb > > I have a form which during the load event creates 1 or more > > checkboxes. Also, as each checkbox is added to the controls > > collection I also add a handler: > > > > AddHandler o.Click, AddressOf MedicationStop_Click > > Do you really want to handle thte Click event or maybe the CheckedChange > event? > > > So, all of the checkboxes use the same handler > > > > That part seems to go well. However, if a user actually checks or > > unchecks one or more of the boxes, I can't seem to determine which > > boxes are checked or their checked state. Can someone show me the > > error of my ways? Here is my handler.. > > > > Private Sub MedicationStop_Click(ByVal sender As System.Object, > > ByVal e As System.EventArgs) > > 'sender' is the sender, AKA checkbox. > > dim chk = directcast(sender, checkbox) > > chk.<whatever> > > > > Armin > > > |