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 6166699
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T22:22:56+00:00 2026-05-23T22:22:56+00:00

Does anybody know the right approach to getting the controls on the form enabled/disabled

  • 0

Does anybody know the right approach to getting the controls on the form enabled/disabled depending on context? The problem is, I have about 50 controls on my form and their states should depend on items selected in some lists, checkboxes checked and some data on the DB exists or not.

Quite rough example is when you have a multi-select tree view and a button like “Compare”. This button should only be enabled when the nodes you’ve selected on the tree view are all of the same kind. Moreover, an additional requirement is, this should be enabled only if you selected 2 nodes. And one more, not every class can be compared, so there’s also a limitation to what exactly you should select to make the comparison possible.

The question is not about Control.Enabled = true/false. The question is about generic approach.

Thanks.

  • 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-05-23T22:22:57+00:00Added an answer on May 23, 2026 at 10:22 pm

    Well in WPF there was something called the Visual State Manager. You could implement something similar in WinForms. Basically your form could have state, and control modifications should only be allowed in states. Then you call a transition to change state. At least all the modification code could then be squirrelled away in methods somewhere called by the state manager.

    http://windowsclient.net/wpf/wpf35/wpf-35sp1-toolkit-visual-state-manager-overview.aspx

    In WPF I think there is some sort of designer support. It would be possible in WinForms following something like how localisation works on forms, but it’s involved.

    I did a crude state manager for one project that took a list of string state names and corresponding delegates to methods to call, then it’s just good practice to keep all modification code in methods and not decorated about the form.

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

Sidebar

Related Questions

Does anybody know how to disable CKEditor's context (right click) menu? I would expect
Does anybody know a good tutorial about Squid plug-in development?
Does anybody know what is the right way to set up a ProtoContract for
Does anybody know if it's possible to open a pop-up form Input Mask which
Does anybody know a tool, preferably for the Explorer context menu, to recursively change
Does anybody know how I can get this xml into the domDocument? Right now,
Does anybody know any good resources for learning how to program CIL with in-depth
Does anybody know a technique to discover memory leaks caused by smart pointers? I
Does anybody know of any sample databases I could download, preferably in CSV or
Does anybody know of a way to list up the loaded plugins in Vim

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.