lunes, 19 de febrero de 2018

Enmascarar caracteres contraseña




Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        DataGridView1.Rows.Add("usuario1", "123456")
        DataGridView1.Rows.Add("usuario2", "abcdef")
    End Sub

    Private Sub DataGridView1_CellFormatting(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellFormattingEventArgs) Handles DataGridView1.CellFormatting
        If e.ColumnIndex = 1 AndAlso e.Value <> Nothing AndAlso Not CheckBox1.Checked Then
            e.Value = New String("*", e.Value.ToString().Length)
        End If
    End Sub

    Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
        DataGridView1.Refresh()
    End Sub
End Class

fuente

No hay comentarios.:

Publicar un comentario