Solved

500pts: Getting the ID from sender in event?

Posted on 2006-06-12
1
243 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

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

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

743 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

15 Experts available now in Live!

Get 1:1 Help Now