Wrox Programmer Forums
|
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 9th, 2004, 10:22 AM
Authorized User
 
Join Date: Nov 2004
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Default CheckBox

I have created a checkbox dynamically. It's local.

chkNew.CheckedChanged += new System.EventHandler(chk_CheckedChanged);


in my chk_CheckChanged function I want to find it's checkstate...

How can I reference this control since it is dynamic?

ie Controls("chk1").CheckState doesn't work

Thanks.

 
Old December 9th, 2004, 11:27 AM
Registered User
 
Join Date: Dec 2004
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Use the sender parameter of your chk_CheckedChanged handler:
private void chk_CheckedChanged(object sender, System.EventArgs e) {
  CheckBox chk = (CheckBox)sender;
  if (chk.CheckState == CheckState.Checked) {
     ...

Chris Jobson





Similar Threads
Thread Thread Starter Forum Replies Last Post
checkbox grstad HTML Code Clinic 1 December 18th, 2006 08:10 AM
checkbox checked by default by html:checkbox sachin.tathod Struts 3 December 4th, 2006 03:41 PM
Need Help regards checkbox nellaikumar ASP.NET 1.0 and 1.1 Basics 1 December 1st, 2005 02:07 PM
Checkbox johnjohn Classic ASP Basics 2 December 6th, 2004 06:03 PM
checkbox damnnono_86 Access 2 October 10th, 2003 03:25 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.