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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T21:14:52+00:00 2026-05-25T21:14:52+00:00

I have an Employee class. There are many departments maintained in the database and

  • 0

I have an Employee class. There are many departments maintained in the database and an employee may only belong to a particular department.

public class Employee
{
    private string name;
    private int depID;

    public string Name
    {
        get { return name; }
        set { name = value; }
    }

    public int DepartmentID
    {
        get { return depID; }
        set { depID = value; }
    }
}

public class Department
{
    private int depID;
    private string depName;

    public int DepartmentID
    {
        get { return depID; }
    }

    public int DepartmentName
    {
        get { return depName; }
        set { depName = value; }
    }
}

How can I display the object Employee in the PropertyGrid with the department as a one of the properties that will be displayed as combobox?

Is it possible? Or is there any better implementation?
Thanks in advance for your inputs.

  • 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-25T21:14:53+00:00Added an answer on May 25, 2026 at 9:14 pm

    I went ahead and drafted you up an experiment (for myself as well since I have never done this). It uses Linq for this particular solution to populate the combo box at hand, but I’m sure you could populate it other ways as well.

    My documentation came from here under the subsection Adding Domain List and Simple Drop-down Property Support

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Linq;
    
    public class Employee : StringConverter
    {
        DataClasses1DataContext mydb = new DataClasses1DataContext();
    
        public override bool GetStandardValuesSupported(ITypeDescriptorContext context)
        {
            return true;
        }
    
        public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
        {
            var a = (from u in mydb.Customers select u.CustomerID).ToArray();
            return new StandardValuesCollection(a);
        }
    
        public string Name { get; set; }
    
        [TypeConverter(typeof(Employee)), CategoryAttribute("Document Settings")]
        public string DepartmentID { get; set; }
    }
    

    On the form load I selected:

     private void Form1_Load(object sender, EventArgs e)
     {
         Employee temp = new Employee();
         propertyGrid1.SelectedObject = temp;
     }
    

    I hope this is what you are looking for. It’s worth noting that you may change StringConverter to TypeConverter if you’d like, but I used String becasue the field I’m dealing with is a string.

    enter image description here

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

Sidebar

Related Questions

I have class with back reference: public class Employee : Entity { private string
I have a Employee class with many attributes. One of the attributes is employeeId
I have an employee class in model for ASP.NET MVC3. There is a field
I have an Employee class object that I am calling from my Login.aspx page's
I have class Employee which is something like this. class Emp { int EmpID;
I have employee as a base class with salaried and hourly employees as derived
I have Employee table and an Entity class for it, My task is such
I have written this clone method for when the parent of the Employee class
I have two tables, one Company and one Employee: class Company(models.Model): name = models.CharField(max_length=60)
I have the following code: class Employee { friend string FindAddr( list<Employee> lst,string name

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.