Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

500pts: Getting the ID from sender in event?

Posted on 2006-06-12
1
Medium Priority
?
266 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 2000 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Integration Management Part 2
Suggested Courses

972 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