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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T03:45:29+00:00 2026-05-14T03:45:29+00:00

I created a simple User Settings Dialog by binding the Property.Settings to a PropertyGrid

  • 0

I created a simple User Settings Dialog by binding the Property.Settings to a PropertyGrid.

This works like a charm but now I would like to allow only certain choices for some values. I have noticed that some Types will give a dropdown of possible choices. This is what I am shooting for but for, say, Strings.

Example, one of the Settings is UserTheme which is a String. Black, Blue, Silver. The program reads that string from the Settings File and sets the Theme on Startup.

I can type in a correct theme and it works but if I type in Pink it will not as there is not a pink option.


This is my VERY simple UserSettingsForm code.

    #region FIELDS

    internal Settings userSettings;

    #endregion

    #region EVENTS

    private void frmEditUserControl_Load(object sender, EventArgs e)
    {
        userSettings = Settings.Default;
        this.propertyGrid1.SelectedObject = userSettings;
        this.propertyGrid1.PropertySort = PropertySort.Alphabetical;
    }

    private void btnSave_Click(object sender, EventArgs e)
    {
        userSettings.Save();
        //this.DialogResult = DialogResult.OK;
        this.Close();
    }

    private void btnCancel_Click(object sender, EventArgs e)
    {
        userSettings.Reload();
        this.Close();
    }

    #endregion

EDIT

Okay, following the advice here I created a library file with my enum in it. Referenced the dll in my main app. Now in settings I see the enum but the dropdown only gives the first enum as an option. Ideas?

namespace psWinForms
{
    public enum UserTheme
    {
        Blue,
        Black,
        Silver,
        Green,
        Pink
    };
}
  • 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-14T03:45:30+00:00Added an answer on May 14, 2026 at 3:45 am

    The Visual studio Settings editor shows a drop down automatically for enumeration types. You can try to create a UserTheme enumeration and test that the PropertyGrid behaves the sames as the Visual Studio Settings editor.

    public enum UserTheme
    {
        Black,
        Blue,
        Silver
    }
    

    Update: I just tested and PropertyGrid automatically shows a drop down for an enumeration type.

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

Sidebar

Related Questions

This seems like a very simple problem, but I cannot get a scrollbox to
Simple question: Should OPTIONAL User Settings be Lazy-Initialized into the DB or always created
This seems like it should be simple but I can't work out how to
I've created a simple webapp with user authentication. I've made two models: Users for
I created a simple Sudoku application, where each 3x3 squares is a user control,
I am trying to create this simple application in c#: when the user double
i've created some Application settings (i.e. not User ) settings in my Visual Studio
Maybe this is simple and I haven't figured it out yet, but I want
Can someone give me a simple example on how to user user-settings instead of
I would like to store a collection of custom objects in a user.config file

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.