question

Flxxer-4101 avatar image
0 Votes"
Flxxer-4101 asked Flxxer-4101 commented

Underlines of MaskedTextBox disappear (Modal Form)

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:

134600-maskedtextbox1.png


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:

134648-maskedtextbox2.png



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.

windows-formsdotnet-visual-basic
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Viorel-1 avatar image
1 Vote"
Viorel-1 answered Flxxer-4101 commented

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.


· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hey @Viorel-1 , you're right. This was my fault. Of course it's If Me._clsfrmChild.Visible = False

0 Votes 0 ·

IIt works with IncludePromptAndLiterals perfectly!! Thank you very much!

0 Votes 0 ·
karenpayneoregon avatar image
0 Votes"
karenpayneoregon answered Flxxer-4101 commented

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)
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hey @karenpayneoregon , unfortunately this did not answer the question.
Do you have another idea?

0 Votes 0 ·