Solved

Accessing a control's properties

Posted on 2007-11-29
3
192 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
[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
  • 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

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

734 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