Try changing the TextMaskFormat of the textbox to IncludePromptAndLiterals.
By the way, ‘If Me._clsfrmChild.ShowDialog = False’ does not seem to have sense because ShowDialog does not return a Boolean value.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hello dear Coders,
I have a problem in Windows Forms. I've created a form where I can click on the search-Button to show another form with the following code:
Private Sub btnSearchUser_Click(sender As Object, e As EventArgs) Handles btnSearchUser.Click
If Me._clsfrmChild Is Nothing Then
Me._clsfrmChild = New clsFrmChild
End If
If Me._clsfrmChild.Visible = False Then
Me._clsfrmChild.ShowDialog(Me)
End If
In the second form I have a MaskedTextbox:
I want to save the value which will be entered but the MaskedTextBox can remain empty as well. But it doesn't matter if the MaskedTextBox is filled or empty.
Whatever I do, if I close the second form with "Visible = False" and reopen it again, the MaskedTextbox looks like this:
I close the second form that way:
Private Sub btnAbort_Click(sender As Object, e As EventArgs) Handles btnAbort.Click
Me.Visible = False
End Sub
Does someone of you know why this problem is caused?
I think the problem has to be with ShowDialog(Me) but I can't replace ShowDialog() because it is required.
Try changing the TextMaskFormat of the textbox to IncludePromptAndLiterals.
By the way, ‘If Me._clsfrmChild.ShowDialog = False’ does not seem to have sense because ShowDialog does not return a Boolean value.
For a test, comment out current code and use this and see if this fixes the issue, if it does then there is code in clsFrmChild preventing the MaskEditTextBox from properly initializing. If there is code in form load, move that code to the Shown event also.
_clsfrmChild = New clsFrmChild
_clsfrmChild.ShowDialog(Me)