Click here to Skip to main content
15,792,382 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to display a combobox of the Operants in the array in the ProperyGid view:
Here is My Code:
My Property Class
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;

namespace AA
    public  class ParameterProperty
        [Category("Parameter Info"), ReadOnlyAttribute(true)]
        public  string Query_ID { get; set; }
        [Category("Parameter Info"), ReadOnlyAttribute(true)]
        public string Parameter_Name { get; set; }
        [Category("Parameter Info"), ReadOnlyAttribute(true)]
        public bool Required { get; set; }
        [Category("Parameter Info"), ReadOnlyAttribute(true)]
        public string Parameter_ID { get; set; }
        [Category("Parameter Info"), ReadOnlyAttribute(true)]
        public int Identity { get; set; }

        public  int Sequence { get; set; }
        public  string Label { get; set; }
        public string Datatype { get; set; }
        public string Value_1 { get; set; }
        public string Value_2 { get; set; }
        public string Operant { get; set;}
        public string[] _Operants = new string[] { "=", ">", "<", "!=" };



This How I load Load The ProperyGrid on my from
ParameterProperty p = new ParameterProperty();
 string s = row["Required"].ToString();
                        p.Query_ID = "A";
                        p.Parameter_ID = 1;
                        p.Sequence = 1;
                        p.Parameter_Name = "A";
                        p.Value_1 = "A";;
                        p.Operant = "A";
                        p.Value_2 = "A";
                        p.Identity = 1
                        propertyGrid1.SelectedObject = p;
Updated 25-Apr-14 0:53am
johannesnestler 25-Apr-14 6:42am    
Before giving long advice how to fiddle with the PropertyGrid I want to ask if your Operants collection shouldn't be an enum (looks fairly finite...), If you make it an enum no further action would be needed (maybe just change the displayed strings like descibed here )Or maybe give it some more "userfriendly" names like equals, greater than... and show the enum values as they are.
ernest_hemingway077 25-Apr-14 7:50am    
Thanks for the Advice for using a enum and userfriendly names. I will have a look that link
BillWoodruff 26-Apr-14 1:58am    
And what appears now in the PropertyGrid when you use it to view the instance of the class ?

1 solution

I Used a enum Type Conveter class
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900