[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Setting an event for an array of radio buttons

Posted on 2011-09-07
7
Medium Priority
?
264 Views
Last Modified: 2012-06-21
My code dynamically creates radio buttons.  How do add a handler to that to point to code?
Dim rbA(16) As RadioButton
        Dim rbH(16) As RadioButton

        For iLoop = 1 To 16

            rbA(iLoop) = New RadioButton
            rbH(iLoop) = New RadioButton

            With rbA(iLoop)

                .Text = "TEST"
                .Checked = False
                .GroupName = "GroupA" & iLoop
                .ID = "Here" & iLoop
                .BackColor = Drawing.Color.SteelBlue

            End With

            Panel1.Controls.Add(rbA(iLoop))

Open in new window

0
Comment
Question by:NOTBOB90
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
7 Comments
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 36499003
Use the AddHanler keyword:
Dim rbA(16) As RadioButton
        Dim rbH(16) As RadioButton

        For iLoop = 1 To 16

            rbA(iLoop) = New RadioButton
            rbH(iLoop) = New RadioButton

            AddHandler rbA(iLoop).CheckChanged, AddressOf Radio_CheckChanged
            AddHandler rbH(iLoop).CheckChanged, AddressOf Radio_CheckChanged

            With rbA(iLoop)

                .Text = "TEST"
                .Checked = False
                .GroupName = "GroupA" & iLoop
                .ID = "Here" & iLoop
                .BackColor = Drawing.Color.SteelBlue

            End With

            Panel1.Controls.Add(rbA(iLoop))

Open in new window

0
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 200 total points
ID: 36499011
P.S.

The syntax for AddHandler is:

AddHandler obj.EventName, AddressOf EventHandlerFunctionName
0
 

Author Comment

by:NOTBOB90
ID: 36499025
This is on the web, not .net.  Will it work like that there?
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 36499118
This is on the web, not .net.  Will it work like that there?
It will add a server-side event handler--though you still need to code the actual handler function. If you want a client-side handler (i.e. javascript), then you would need to use the ScriptManager.
0
 

Author Comment

by:NOTBOB90
ID: 36499827

WHen I do this:

AddHandler rbH(iLoop).CheckChanged, AddressOf proRadioClick

I get this error hovering over checkchanged

checkchanged is not an event of system.web.ui..webcontrols.radiobutton
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 36499977
I was just throwing an event out as an example. The correct name is CheckedChanged. See here for more details.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
The purpose of this article is to demonstrate how we can use conditional statements using Python.
The viewer will learn how to implement Singleton Design Pattern in Java.
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
Suggested Courses

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question