private void FormatStringDialog_Load(object sender, EventArgs e) { string str = (this.dgvCellStyle != null) ? this.dgvCellStyle.Format : this.listControl.FormatString; object obj2 = (this.dgvCellStyle != null) ? this.dgvCellStyle.NullValue : null; string str2 = string.Empty; if (!string.IsNullOrEmpty(str)) { str2 = FormatControl.FormatTypeStringFromFormatString(str); } if (this.dgvCellStyle != null) { this.formatControl1.NullValueTextBoxEnabled = true; } else { this.formatControl1.NullValueTextBoxEnabled = false; } this.formatControl1.FormatType = str2; FormatControl.FormatTypeClass formatTypeItem = this.formatControl1.FormatTypeItem; if (formatTypeItem != null) { formatTypeItem.PushFormatStringIntoFormatType(str); } else { this.formatControl1.FormatType = System.Design.SR.GetString("BindingFormattingDialogFormatTypeNoFormatting"); } this.formatControl1.NullValue = (obj2 != null) ? obj2.ToString() : ""; }
private void propertiesTreeView_AfterSelect(object sender, TreeViewEventArgs e) { if (!this.inLoad) { BindingTreeNode node = e.Node as BindingTreeNode; if (node == null) { this.dataSourcePicker.Binding = null; this.bindingLabel.Enabled = this.dataSourcePicker.Enabled = false; this.updateModeLabel.Enabled = this.bindingUpdateDropDown.Enabled = false; this.formatControl1.Enabled = false; } else { this.bindingLabel.Enabled = this.dataSourcePicker.Enabled = true; this.dataSourcePicker.PropertyName = node.Text; this.updateModeLabel.Enabled = this.bindingUpdateDropDown.Enabled = false; this.formatControl1.Enabled = false; if (node.Binding != null) { this.formatControl1.Enabled = true; this.formatControl1.FormatType = node.FormatType; FormatControl.FormatTypeClass formatTypeItem = this.formatControl1.FormatTypeItem; this.dataSourcePicker.Binding = node.Binding; formatTypeItem.PushFormatStringIntoFormatType(node.Binding.FormatString); if (node.Binding.NullValue != null) { this.formatControl1.NullValue = node.Binding.NullValue.ToString(); } else { this.formatControl1.NullValue = string.Empty; } this.bindingUpdateDropDown.SelectedItem = node.Binding.DataSourceUpdateMode; this.updateModeLabel.Enabled = this.bindingUpdateDropDown.Enabled = true; } else { bool dirty = this.dirty; this.dataSourcePicker.Binding = null; this.formatControl1.FormatType = node.FormatType; this.bindingUpdateDropDown.SelectedItem = this.bindings.DefaultDataSourceUpdateMode; this.formatControl1.NullValue = null; this.dirty = dirty; } this.formatControl1.Dirty = false; this.currentBindingTreeNode = node; } } }
private void FormatStringDialog_Load(object sender, EventArgs e) { // make a reasonable guess what user control should be shown string formatString = _dgvCellStyle != null ? _dgvCellStyle.Format : _listControl.FormatString; object nullValue = _dgvCellStyle != null ? _dgvCellStyle.NullValue : null; string formatType = string.Empty; if (!string.IsNullOrEmpty(formatString)) { formatType = FormatControl.FormatTypeStringFromFormatString(formatString); } // the null value text box should be enabled only when editing DataGridViewCellStyle // when we are editing ListControl, it should be disabled if (_dgvCellStyle != null) { _formatControl1.NullValueTextBoxEnabled = true; } else { Debug.Assert(_listControl != null, "we check this everywhere, but it does not hurt to check it again"); _formatControl1.NullValueTextBoxEnabled = false; } _formatControl1.FormatType = formatType; // push the information from FormatString/FormatInfo/NullValue into the FormattingUserControl FormatControl.FormatTypeClass formatTypeItem = _formatControl1.FormatTypeItem; if (formatTypeItem != null) { // parsing the FormatString uses the CultureInfo. So push the CultureInfo before push the FormatString. formatTypeItem.PushFormatStringIntoFormatType(formatString); } else { // make General format type the default _formatControl1.FormatType = SR.BindingFormattingDialogFormatTypeNoFormatting; } _formatControl1.NullValue = nullValue != null?nullValue.ToString() : ""; }