Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9022361
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T05:29:24+00:00 2026-06-16T05:29:24+00:00

In my WPF application, I displayed some Checkbox dynamically. The Name and Content of

  • 0

In my WPF application, I displayed some Checkbox dynamically. The Name and Content of these Checkbox come from a Table in the Database.

...
StackPanel innerStack = new StackPanel();
        List<Course> courses = ldc.Courses.ToList();
        var count = courses.Count();
        var b = ldc.Books.Single(x=>x.BookID==1);
        foreach (var c in courses)
        {
            CheckBox cb = new CheckBox();
            cb.Name = c.CourseID.ToString();
            cb.Content = c.CourseID.ToString();
            var x = from bc in ldc.CourseAndBooks
                    where bc.BookID == b.BookID
                    select bc.CourseID;
            if (x.Contains(c.CourseID))
            {
                cb.IsChecked = true;
            }

            cb.AddHandler(CheckBox.CheckedEvent, new RoutedEventHandler(course_Checked));
            cb.AddHandler(CheckBox.UncheckedEvent, new RoutedEventHandler(course_Unchecked));
            innerStack.Children.Add(cb);
        }
        Grid.SetColumn(innerStack,0);
        Grid.SetRow(innerStack,0);
        Grid.SetColumnSpan(innerStack,1);
        Grid.SetRowSpan(innerStack,1);
        grid.Children.Add(innerStack);
        ...

I added Checked and Unchecked event too to manipulate the checked item in the Database.

 private void course_Checked(object sender, RoutedEventArgs e)
    { 
        MessageBox.Show("checked"); // it works
        // How to identify cb.Name here to perform some database query?
    }
    private void course_Unchecked(object sender, RoutedEventArgs e)
    {
        MessageBox.Show("Unchecked"); // it works
        // How to identify cb.Name here to perform some database query?
    }

So, how can I get the name of the checked/unchecked Checkbox name in the Checked/Unchecked` event method. Any suggession ? Thankyou.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T05:29:25+00:00Added an answer on June 16, 2026 at 5:29 am

    Fairly sure you can cast the sender to a CheckBox and it will be what you’re looking for.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to bind to some XML data from my WPF application. I've set
I have a WPF MVVM application which stores some text in a database (nvarchar).
My WPF application uses Entity Framework 4.0 with a SQL Server CE database. And
I have a WPF application in which a thread checks some value. In certain
I have a WPF application that uses Caliburn.Micro. I have a DataGrid: <DataGrid x:Name=WeatherStations
i am porting my application from windows forms to WPF. I have found that
I am developing a WPF MVVM Light application, I want to display some message
In my WPF application, I host Win32 content using HwndHost. However, creating a HwndHost
We currently have a WPF application showing some 3D schema and we have made
I have a WPF application with a few dozen user panels displayed in a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.