Solved

Accessing a control's properties

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
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…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

776 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