private void FormatComboBox_SelectedIndexChanged(object sender, EventArgs e) { DateTimePickerFormat format = (DateTimePickerFormat)FormatComboBox.SelectedItem; SampleDateTimePicker.Format = format; DateTimePickerLayoutPanel.PerformLayout(); UpdateCustomFormatTextBox(); }
private void ProcessCustomFormatPatternTextBoxTextChanging() { string text = CustomFormatTextBox.Text; int currentQuoteCharIndex = 0, lastQuoteCharIndex = -1, quoteCharCount = 0; while ((currentQuoteCharIndex = text.IndexOf('\'', currentQuoteCharIndex)) != -1) { quoteCharCount += 1; lastQuoteCharIndex = currentQuoteCharIndex; currentQuoteCharIndex += 1; } if (quoteCharCount % 2 != 0) { text = text.Remove(lastQuoteCharIndex, 1); } SampleDateTimePicker.CustomFormat = text; DateTimePickerLayoutPanel.PerformLayout(); }