comment mettre un cellule d'un datagridview en" passwordchar"
salut
j'ai le programme suivant qui permet de charger une table USERS dans un DataGridView
la connexion cn est définie en Public dans un module .
Code:
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 31 32 33 34
| Imports System.Data.OleDb
Public Class frmGestUtil
Private Sub frmGestUtil_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim CmdUsers As New OleDbCommand
Dim DrUsers As OleDbDataReader
If Cn.State = ConnectionState.Open Then
Cn.Close()
End If
Cn.Open()
DGV.Enabled = True
DGV.DataSource = Nothing
If Cn.State = ConnectionState.Open Then
CmdUsers.CommandType = CommandType.Text
CmdUsers.CommandText = "SELECT * FROM USERS; "
CmdUsers.Connection = Cn
DrUsers = CmdUsers.ExecuteReader
If DrUsers.HasRows Then
Dim t As New DataTable
t.Load(DrUsers)
DGV.DataSource = t
DrUsers.Close()
Cn.Close()
DGV.Focus()
Else
MsgBox("pas de données dans la table...", vbExclamation + vbMsgBoxRtlReading, "attention...")
End If
Else
MsgBox(Err.Number, 0 + 16, Err.Description)
End If
End Sub
End Class |
Je souhaite cripter le contenu du 3ème champ appelé "PassWord", c'est à dire rendre les cellules de la 3ème colonne du DataGridView au format Passwordchar comme celui des textbox
merci
c'est facille avec ce code
Code:
1 2 3 4 5 6
| Private Sub DGV_CellFormatting(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellFormattingEventArgs) Handles DGV.CellFormatting
If e.RowIndex > DGV.Rows.Count() OrElse e.RowIndex < 0 OrElse DGV.Rows(e.RowIndex) Is Nothing OrElse DGV.Rows(e.RowIndex).DataBoundItem Is Nothing Then
e.Value = Nothing
ElseIf e.ColumnIndex = 2 Then
e.Value = "******"
End If |