Solved

500pts: Getting the ID from sender in event?

Posted on 2006-06-12
1
248 Views
Last Modified: 2010-04-16
Hi there,

Can anybody help?

I have an event (click) that i have assigned to lots of Checkboxes.

And in that click evetn... i wil to add the name to of the item that was Checked or unchecked to a listbox

But how do i know which control was clicked as they all share the same event... i thought it might be the sender (see below)

            private void uxFieldsCheckBox_CheckedChanged(object sender, System.EventArgs e)
            {
                  ListBox test = new(ListBox)sender;
                  
                  // uxOrderListBox.Items.Add(  
            }

Thanks in advance ...

Ian
0
Comment
Question by:ianinspain
1 Comment
 
LVL 25

Accepted Solution

by:
dstanley9 earned 500 total points
ID: 16885988
Well, you're close, but is the sender is a CheckBox, it should be:

          private void uxFieldsCheckBox_CheckedChanged(object sender, System.EventArgs e)
          {
               CheckBox test = sender as CheckBox;
               if (test != null)
               { // is is indeed a CheckBox
                 
                 uxOrderListBox.Items.Add(test.Text);
               }
          }
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

Suggested Solutions

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
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