private void setComboBox(ComboBox cbox, XmlInputConfiguration xmlConfig, string key, XmlElement[] eIncomingMetaInfo) { string target = (string)xmlConfig[key]; cbox.Items.Clear(); if (eIncomingMetaInfo == null || eIncomingMetaInfo[0] == null) { // No incoming connection; Just add the field and select it cbox.Items.Add(target); cbox.SelectedIndex = 0; } else { // We have an incoming connection var xmlElementMetaInfo = eIncomingMetaInfo[0]; var xmlElementRecordInfo = xmlElementMetaInfo.FirstChild; foreach (XmlElement elementChild in xmlElementRecordInfo) { string fieldName = elementChild.GetAttribute("name"); string fieldType = elementChild.GetAttribute("type"); if (isStringType(fieldType)) { cbox.Items.Add(fieldName); } } // If the messageField matches a possible field in the combo box, make it the selected field. // If the field does not match, do not select anything and blank the field. if (!string.IsNullOrWhiteSpace(target)) { int selectedIndex = cbox.FindStringExact(target); if (selectedIndex >= 0) { cbox.SelectedIndex = selectedIndex; // Found; Select this item } } } // end of "if (eIncomingMetaInfo == null || eIncomingMetaInfo[0] == null)" }
public Control GetConfigurationControl( AlteryxGuiToolkit.Document.Properties docProperties, XmlElement eConfig, XmlElement[] eIncomingMetaInfo, int nToolId, string strToolName) { XmlInputConfiguration xmlConfig = XmlInputConfiguration.LoadFromConfiguration(eConfig); if (xmlConfig == null) { return(this); } /////////////////////////////////////////////////////////////////// // Populate GUI Controls with saved config information // /////////////////////// // FIELD COMBOX BOXES // setComboBox(comboBoxDataField, xmlConfig, "DataField", eIncomingMetaInfo); setComboBox(comboBoxSchemaField, xmlConfig, "SchemaField", eIncomingMetaInfo); /////////////////////////////////////////////////////////////////// // Output Field // string outputField = xmlConfig.OutputField; textBoxOutputField.Text = outputField; return(this); }