Solved

Accessing a control's properties

Posted on 2007-11-29
3
153 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

760 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now