Solved

500pts: Getting the ID from sender in event?

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

839 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