I am currently fetching the all fields/attributes of feature class and display in Combo box parameter using below code:

paramEdit = new GPParameterClass();
paramEdit.DataType = new DEFeatureClassType() as IGPDataType;
paramEdit.Value = new DEFeatureClass() as IGPValue;
paramEdit.Direction = esriGPParameterDirection.esriGPParameterDirectionInput;
paramEdit.DisplayName = "Feature Class 1";
paramEdit.DisplayOrder = inputTable1Index;
paramEdit.Enabled = true;
paramEdit.Name = "in_line_featureclass1";
paramEdit.ParameterType = esriGPParameterType.esriGPParameterTypeRequired;
paramEdit.Domain = lineFeatureClassDomain as IGPDomain;

paramEdit = new GPParameterClass();
paramEdit.DataType = (IGPDataType)new FieldType();
paramEdit.Value = (IGPValue)new Field();                
paramEdit.Direction = esriGPParameterDirection.esriGPParameterDirectionInput;
paramEdit.DisplayName = "Select attributes from Feature Class 1";
paramEdit.DisplayOrder = inputDynamicList1Index;
paramEdit.Enabled = true;
paramEdit.Name = "in_line_featureclass1_attrib";
paramEdit.ParameterType = esriGPParameterType.esriGPParameterTypeOptional;
IGPFeatureSchema outputSchema = new GPFeatureSchemaClass();
IGPSchema schema = (IGPSchema)outputSchema;                
schema.CloneDependency = true;
paramEdit.Schema = outputSchema as IGPSchema;

I want to hide some fields which display in this combo box parameter.

Is it possible to hide the fields or display selected fields from feature class ?

enter image description here

As shown in above image when I selecting feature class it display the fields of that feature class in combo box but I want to hide some fields in that combo box so how can I do this?

  • I'm really not sure what you're trying to do here.. you talk about a combo box but are showing code with gp parameter object. Jun 28 '17 at 4:30
  • @Michael Stimson I have updated the question. Using the code I have written above it display output as shown in image I attached.
    – Vicky
    Jun 28 '17 at 4:36
  • Oh, it's not a Windows form combo box, it's a geoprocessor dialog box. That makes the question clearer but unfortunately I can't help, I've not used that interface. Jun 28 '17 at 4:54

Finally I found the solution for this if we want to hide the field according to particular data types then we need to set domain for this. In my case I don't want to display a SHAPE field i.e. Geometry fields in combo box parameter, so I have set the domain like below:

IGPFieldDomain fieldDomain = new GPFieldDomainClass();

i.e. I have set domain for all fields except geometry so this will not display geometry type fields in combo box.

and set this domain to parameter like:

paramEdit.Domain = fieldDomain as IGPDomain;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.