all groups > vb.net controls > july 2006 >
You're in the

vb.net controls

group:

PasswordChar


PasswordChar Massimo
7/26/2006 3:38:11 PM
vb.net controls:
Is it possible to set the passwordchar property to a column or a cell of a
datagridview to view the * characters when user digits?

Thanks, Max

Re: PasswordChar Ken Tucker [MVP]
7/26/2006 10:53:58 PM
Hi,

Try this. I am making the first column a password column

Public Class Form1
Dim bs As New BindingSource

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim strConn As String = _
"Server = .;Database = NorthWind;" & _
"Integrated Security = SSPI;"
Dim conn As New SqlClient.SqlConnection(strConn)
Dim dt1 As New DataTable
Dim da1 As New SqlClient.SqlDataAdapter _
("Select * from Orders", conn)
da1.Fill(dt1)
bs.DataSource = dt1
DataGridView1.DataSource = bs
BindingNavigator1.BindingSource = bs
End Sub


Private Sub DataGridView1_CellFormatting(ByVal sender As Object, ByVal e
As System.Windows.Forms.DataGridViewCellFormattingEventArgs) Handles
DataGridView1.CellFormatting
If e.ColumnIndex = 0 Then
e.Value = New String("*", e.Value.ToString.Length)
End If

End Sub

Private Sub DataGridView1_EditingControlShowing(ByVal sender As Object,
ByVal e As System.Windows.Forms.DataGridViewEditingControlShowingEventArgs)
Handles DataGridView1.EditingControlShowing
If DataGridView1.CurrentCell.ColumnIndex = 0 Then
DirectCast(e.Control, TextBox).PasswordChar = "*"
End If
End Sub
End Class

Ken
--------------------
[quoted text, click to view]

Re: PasswordChar Massimo
7/27/2006 12:00:00 AM
"Ken Tucker [MVP]" <vb2ae@bellsouth.net> ha scritto nel messaggio
news:udad1fSsGHA.4456@TK2MSFTNGP04.phx.gbl...
[quoted text, click to view]

Thanks a lot, Max

AddThis Social Bookmark Button