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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:09:13+00:00 2026-06-14T20:09:13+00:00

I have a property grid with 2 items. Country & Cities. I have 1

  • 0

I have a property grid with 2 items. Country & Cities. I have 1 table in database : CountryCityTable that save LocationId, Title , ParentId. For countries parentId = 0 and for cities is countryid.

In my propertygrid, I use these and show in 2 combobox items. Please see my code :

namespace ProGrid
{
    public class KeywordProperties
    {
        [TypeConverter(typeof(CountryLocationConvertor))]
        public string CountryNames { get; set; }

        [TypeConverter(typeof(CityLocationConvertor))]
        public string CityNames { get; set; }
    }
}

And

namespace ProGrid
{
    public class CountryLocationConvertor : StringConverter 
    {
        public override bool GetStandardValuesSupported(ITypeDescriptorContext context)
        {
            return true;
        }

        public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
        {            
            HumanRoles Db = new HumanRoles();
            List<LocationsFieldSet> Items = new List<LocationsFieldSet>();
            Items = Db.LoadLocations(0,0);
            string[] LocationItems = new string[Items.Count];
            int count = 0;
            foreach (LocationsFieldSet Item in Items)
            {
                LocationItems[count] = Item.Title;
                count++;
            }
            return new StandardValuesCollection(LocationItems);
        }

        public override bool GetStandardValuesExclusive(ITypeDescriptorContext context)
        {
            return true;//false : If you want the user to be able to type in a value that is not in the drop-down list.
        }
    }

    public class CityLocationConvertor : StringConverter
    {
        public override bool GetStandardValuesSupported(ITypeDescriptorContext context)
        {
            return true;
        }

        public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
        {
            HumanRoles Db = new HumanRoles();
            List<LocationsFieldSet> Items = new List<LocationsFieldSet>();
            Items = Db.LoadLocations(1,20);
            string[] LocationItems = new string[Items.Count];
            int count = 0;
            foreach (LocationsFieldSet Item in Items)
            {
                LocationItems[count] = Item.Title;
                count++;
            }
            return new StandardValuesCollection(LocationItems);
        }

        public override bool GetStandardValuesExclusive(ITypeDescriptorContext context)
        {
            return true;
        }
    }
}

And

KeywordProperties Kp = new KeywordProperties();
myPropertyGrid.SelectedObject = Kp;

Now, I want when user changed country title in propertygrid, List of cities updated(just display cities that parentid of these = countryid).

Also, in my class how can i change Number 20 in my code(Db.LoadLocations(1,20);) to selected country id ?

Thank’s.

  • 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-14T20:09:15+00:00Added an answer on June 14, 2026 at 8:09 pm

    You will need to implement something similar to INotifyPropertyChanged

    Microsoft INotifyPropertyChange Documentation

    In other word, you will need to have some event raised when you chance one property. As far as I remember, the property grid automaticly check for that type of event/interface and refresh the correct property node when the event is raised.

    The important part is:

    private void NotifyPropertyChanged([CallerMemberName] String propertyName = "")
    {
        if (PropertyChanged != null)
        {
            PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
        }
    }
    

    and

    public bool MyBoolProperty
    {
        get { return  myBoolField; }
        set
        {
            myBoolField = value;
            NotifyPropertyChanged();
        }
    }
    

    If you want to do something that is not covered by the PropertyGrid, you simply need to register your own method in the PropertyChanged event and do whatever you please.

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

Sidebar

Related Questions

I have a FileNameEditor inside a property grid, which has a few entries like
i have a doubt in grid view. In Data list we have a property
I have a property in my backing bean that returns html code: public String
I have a user control that allows items to be added to it by
I have an custom control that represents a grid; and implements another custom control.
I have a data grid in a view that is bound to a List
I have a class which is displayed in a property grid. One of the
OK, I have a data template for items: <DataTemplate x:Key=SmallDayEventItemTemplate> <Border ...> <Grid ...>
I have a treeView and a stackpanel with message that There is no items.
I have a Listbox that is filled with 30,000 elements <ListBox Name=lbWordlist Grid.Row=1 Margin=10

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.