void PropertyGrid_KeyDown(object sender, KeyEventArgs e) { // If DisplayFormat field and Insert is pushed if (propertyGrid.SelectedGridItem.Label == "DisplayFormat" && e.KeyCode == Keys.Insert && !e.Alt && !e.Control && !e.Shift) { Type selectedObjectType = ((Property)propertyGrid.SelectedObject).Type; Property property = propertyGrid.SelectedObject as Property; using (SelectDisplayFormats form = new SelectDisplayFormats()) { form.DisplayFormat = property.DisplayFormat; form.DisplayFormatDataType = selectedObjectType; form.IsEditable = false; if (form.ShowDialog() == DialogResult.OK) { property.DisplayFormat = form.DisplayFormat; propertyGrid.Refresh(); AskSaveProperty(); } } } }
void SourceGrid_KeyDown(object sender, KeyEventArgs e) { // If DisplayFormat field and Insert is pushed if (sourceGrid.SelectedGridItem.Label == "DisplayFormat" && e.KeyCode == Keys.Insert && !e.Alt && !e.Control && !e.Shift) { Type selectedObjectType = ((MappedProperty)sourceGrid.SelectedObject).Type; MappedProperty property = sourceGrid.SelectedObject as MappedProperty; using (SelectDisplayFormats form = new SelectDisplayFormats()) { form.DisplayFormat = property.DisplayFormat; form.DisplayFormatDataType = selectedObjectType; if (form.ShowDialog() == DialogResult.OK) { property.DisplayFormat = form.DisplayFormat; sourceGrid.Refresh(); } } } }
private void btnBrowseDisplayFormat_Click(object sender, EventArgs e) { using (SelectDisplayFormats form = new SelectDisplayFormats()) { form.DisplayFormat = tbDisplayFormat.Text; form.DisplayFormatDataType = EditMappedProperty.Type; form.IsEditable = this.IsEditable; if (form.ShowDialog() == DialogResult.OK) { tbDisplayFormat.Text = form.DisplayFormat; } } }