private void ComboBoxEx_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (SelectedItem != null) { ComboBoxItemDetails item = (ComboBoxItemDetails)SelectedItem; if (_lastKey == null || item.ID != _lastKey) { _lastKey = item.ID; if (!publishing) { _controlHarness.SendXml(DeltaXml); } } } }
public virtual void PublishData(XElement data) { publishing = true; _lastKey = null; try { XElement ColumnDefintions = data.Element(Common.Data.Columns); XElement Rows = data.Element(Common.Data.Rows); _items.Clear(); if (Rows == null || ColumnDefintions == null) { return; } string columnToUse = null; // Determine which column to display in the list if (!string.IsNullOrEmpty(DisplayTextColumn)) { // Use the column specified by the client XElement displayColumn = ColumnDefintions.Elements(Common.Data.Column).Where(x => x.Attribute(Common.Data.ColumnField).Value == DisplayTextColumn).FirstOrDefault(); if (displayColumn != null) { columnToUse = displayColumn.GetAttributeValue(Common.IDAttrib); } } else { // Use the first *string* column that has a width XNode columnNode = ColumnDefintions.FirstNode; while (columnToUse == null && columnNode != null) { if (columnNode is XElement) { XElement element = (XElement)columnNode; int theWidth = 0; string dataType = element.GetAttributeValue(Common.Datatypes.AttribName); if (element.Attribute(Common.Data.ColumnWidth) != null) { int.TryParse(element.Attribute(Common.Data.ColumnWidth).Value, out theWidth); } if (theWidth != 0 && dataType == Common.Datatypes.String) { columnToUse = element.Attribute(Common.IDAttrib).Value; } } columnNode = columnNode.NextNode; } } // Always add an empty or null entry if (wantNullEntry) { var nullItem = new ComboBoxItemDetails("", NullEntryText, Common.Null); _items.Add(nullItem); } XNode node = Rows.FirstNode; while (node != null) { if (node is XElement) { XElement rowData = (XElement)node; string id = rowData.Attribute(Common.IDAttrib).Value; string type = rowData.GetAttributeValue(Common.Data.RowType); string displayText = null; XElement displayColumn = rowData.Elements("Cell").Where(x => x.Attribute("id").Value == columnToUse).FirstOrDefault(); if (displayColumn != null) { displayText = displayColumn.Value; if (id.Length == 0) { id = displayColumn.Value; } } var item = new ComboBoxItemDetails(id, displayText, type); _items.Add(item); } node = node.NextNode; } } finally { publishing = false; } }
public virtual void PublishData(XElement data) { publishing = true; _lastKey = null; try { XElement ColumnDefintions = data.Element(Common.Data.Columns); XElement Rows = data.Element(Common.Data.Rows); _items.Clear(); if (Rows == null || ColumnDefintions == null) return; string columnToUse = null; // Determine which column to display in the list if (!string.IsNullOrEmpty(DisplayTextColumn)) { // Use the column specified by the client XElement displayColumn = ColumnDefintions.Elements(Common.Data.Column).Where(x => x.Attribute(Common.Data.ColumnField).Value == DisplayTextColumn).FirstOrDefault(); if (displayColumn != null) columnToUse = displayColumn.GetAttributeValue(Common.IDAttrib); } else { // Use the first *string* column that has a width XNode columnNode = ColumnDefintions.FirstNode; while (columnToUse == null && columnNode != null) { if (columnNode is XElement) { XElement element = (XElement)columnNode; int theWidth = 0; string dataType = element.GetAttributeValue(Common.Datatypes.AttribName); if (element.Attribute(Common.Data.ColumnWidth) != null) int.TryParse(element.Attribute(Common.Data.ColumnWidth).Value, out theWidth); if (theWidth != 0 && dataType == Common.Datatypes.String) columnToUse = element.Attribute(Common.IDAttrib).Value; } columnNode = columnNode.NextNode; } } // Always add an empty or null entry if (wantNullEntry) { var nullItem = new ComboBoxItemDetails("", NullEntryText, Common.Null); _items.Add(nullItem); } XNode node = Rows.FirstNode; while (node != null) { if (node is XElement) { XElement rowData = (XElement)node; string id = rowData.Attribute(Common.IDAttrib).Value; string type = rowData.GetAttributeValue(Common.Data.RowType); string displayText = null; XElement displayColumn = rowData.Elements("Cell").Where(x => x.Attribute("id").Value == columnToUse).FirstOrDefault(); if (displayColumn != null) { displayText = displayColumn.Value; if (id.Length == 0) id = displayColumn.Value; } var item = new ComboBoxItemDetails(id, displayText, type); _items.Add(item); } node = node.NextNode; } } finally { publishing = false; } }