Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,
I want to display a combobox of the Operants in the array in the ProperyGid view:
Here is My Code:
My Property Class
C#
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; }

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


           
        }
      

    }

This How I load Load The ProperyGrid on my from
C#
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;
Posted
Updated 24-Apr-14 23:53pm
v2
Comments
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 http://stackoverflow.com/questions/7422685/edit-the-display-name-of-enumeration-members-in-a-propertygrid )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