2020年5月15日 星期五

vb.net Combobox的mask寫法 [ComboBox Apply mask]


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
    Private Sub cboScript_KeyDown(sender As Object, e As KeyEventArgs) Handles cboScript.KeyDown

        Dim strSufijo As String = ".ini"


        If e.KeyCode = Keys.Delete Then

            If cboScript.SelectionStart >= cboScript.Text.Length - strSufijo.Length Then

                e.SuppressKeyPress = True

            End If

        End If


        If cboScript.SelectionStart > cboScript.Text.Length - strSufijo.Length Then

            cboScript.Text = cboScript.Text.ToString.Replace(strSufijo, "") & strSufijo

            cboScript.Select(cboScript.Text.Length - strSufijo.Length, 0)

        Else

            cboScript.Text = cboScript.Text.ToString.Replace(strSufijo, "") & strSufijo

        End If


    End Sub

沒有留言:

張貼留言