Beispiel #1
0
        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() : "";
        }
Beispiel #2
0
        private void PushChanges()
        {
            FormatControl.FormatTypeClass formatTypeItem = _formatControl1.FormatTypeItem;

            if (formatTypeItem == null)
            {
                return;
            }

            if (_dgvCellStyle != null)
            {
                _dgvCellStyle.Format    = formatTypeItem.FormatString;
                _dgvCellStyle.NullValue = _formatControl1.NullValue;
            }
            else
            {
                _listControl.FormatString = formatTypeItem.FormatString;
            }

            _dirty = true;
        }