Posted 16 September 2024, 10:58 pm EST
To wknauf and uttkarsh.matiyal
Thanks for your reply. I also tried it, and in the sample project, there was no problem.
But I have a concern about whether calling too many ValueChanged events will affect the project. Can you give me some advice
my problem
I have two C1DateEdit controls: startDate and endDate.
When I edit the startDate, I want the endDate value to be automatically updated(endDate is always 1 month after the startDate).
In the current version all processing is done in TextChanged
Public Class DateEditEx
Inherits C1.Win.Calendar.C1DateEdit
Private _oldValue As Object = Nothing
Protected Overrides Sub OnValueChanged(e As EventArgs)
If _oldValue <> Value Then
MyBase.OnValueChanged(e)
End If
End Sub
Protected Overrides Sub OnTextChanged(e As EventArgs)
Try
Select Case CustomFormat
'日本語の字のケース
Case "yyyy/M/d(ddd)"
Case "yyyy/MM/dd(ddd)"
Dim cleanedString As String = Text.Substring(0, Text.IndexOf("("c))
Value = Date.ParseExact(cleanedString, "yyyy/MM/dd", Globalization.CultureInfo.InvariantCulture)
'Case "yyyy年"
' Value = Date.ParseExact(Text, "yyyy年", Globalization.CultureInfo.InvariantCulture)
'Case "yyyy年M月"
' Value = Date.ParseExact(Text, "yyyy年M月", Globalization.CultureInfo.InvariantCulture)
'Case "yyyy年MM月"
' Value = Date.ParseExact(Text, "yyyy年MM月", Globalization.CultureInfo.InvariantCulture)
Case Else
Me.Value = Date.ParseExact(Text, Me.CustomFormat, Globalization.CultureInfo.InvariantCulture)
End Select
_oldValue = Value
Catch ex As Exception
Finally
MyBase.OnTextChanged(e)
End Try
End Sub
End Class