Solved

Accessing a control's properties

Posted on 2007-11-29
3
189 Views
Last Modified: 2010-04-23
I have one sub where I dynamically create checkboxlist items...

Dim chk As New CheckBox
   With chk
        AddHandler chk.CheckStateChanged, AddressOf chkBox_CheckedChanged
        .Name = strName

In that checkstatechanged event, I'm trying to set another created control's name based off the checkbox's name:

    Private Sub chkBox_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Dim cbo as New CustomCombo
        cbo.Name = "Primary " & chkBox.Name

but that gives me the error: Name 'chkbox' is not declared

How can I get around this?
0
Comment
Question by:sirbounty
  • 2
3 Comments
 
LVL 38

Accepted Solution

by:
PaulHews earned 250 total points
ID: 20376410
Here's a case where you can use the sender parameter:

Private Sub chkBox_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Dim cbo as New CustomCombo
        Dim chkBox As CheckBox = DirectCast(sender, CheckBox)
        cbo.Name = "Primary " & chkBox.Name
0
 
LVL 38

Expert Comment

by:PaulHews
ID: 20376419
I don't think you can have a space in a control name however...
0
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 20376466
it is no chk?
cbo.Name = "Primary " & chk.Name
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

680 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