private void sourceGrid_SelectedGridItemChanged(object sender, SelectedGridItemChangedEventArgs e) { foreach (Control cntrl in sourceGrid.Controls[2].Controls) { cntrl.KeyDown -= new KeyEventHandler(SourceGrid_KeyDown); } lblInformation.Text = string.Empty; if (e.NewSelection != null && e.NewSelection.Label == "DisplayFormat") { MappedProperty mappedProperty = (MappedProperty)sourceGrid.SelectedObject; // Check if the type is one of DateTime or Numeric (decimal, double or int) if (mappedProperty != null && mappedProperty.CanChangeDisplayFormat()) { lblInformation.Text = "Push the \"Insert\" button in the inputfield for help on different used DisplayFormats."; foreach (Control cntrl in sourceGrid.Controls[2].Controls) { cntrl.KeyDown += new KeyEventHandler(SourceGrid_KeyDown); } } } }
private void btnSaveMulti_Click(object sender, EventArgs e) { if (propertyListView.SelectedItems.Count > 1 && ChangedMultiSelProperties.Count > 0) { string showMessage = string.Format("Updating {0} selected item(s) with the following:\n\n", propertyListView.SelectedItems.Count); foreach (KeyValuePair <string, object> keyVal in ChangedMultiSelProperties) { showMessage += string.Format("{0} = {1}\n", keyVal.Key, keyVal.Value ?? "[null]"); } showMessage += "\nDo you want to write these changes to the selected item(s)?"; if (MessageBox.Show(showMessage, "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes) { foreach (ListViewItem item in propertyListView.SelectedItems) { MappedProperty property = item.Tag as MappedProperty; foreach (KeyValuePair <string, object> keyVal in ChangedMultiSelProperties) { // Check if we are changing DisplayFormat if we should update it if (keyVal.Key == "DisplayFormat") { if (!property.CanChangeDisplayFormat()) { continue; } } // Set the value with reflection property.GetType().GetProperty(keyVal.Key).SetValue(property, keyVal.Value, null); } UpdateListItem(item); } } } }