tagCANDY CGI VBレスキュー(花ちゃん) の Visual Basic 2010 用 掲示板(VB.NET 掲示板)
VBレスキュー(花ちゃん) の Visual Basic 2010 用 掲示板(VB.NET 掲示板)
[ツリー表示へ]  [ワード検索]  [Home]

タイトル Re: DataGridViewのパスワード入力
投稿日: 2006/10/04(Wed) 14:43
投稿者うなまな
カスタムセルを作成して対応できるかと思いましたが、表示時の制御が難しく、理想的でなかった
ので、CellFormatting、EditingControlShowingイベントで実装してみました。
列名がPasswordの場合に*表示させます。(細かなチェックは未・・・)

Private Sub DataGridView1_CellFormatting(ByVal sender As Object, _
                       ByVal e As System.Windows.Forms.DataGridViewCellFormattingEventArgs) _
                                 Handles DataGridView1.CellFormatting
    If e.ColumnIndex = Me.DataGridView1.Columns("Password").Index Then
        If e.Value IsNot Nothing Then
            e.Value = New String("*"c, e.Value.ToString.Length)
        End If
    End If
End Sub


Private Sub DataGridView1_EditingControlShowing(ByVal sender As Object, _
                       ByVal e As System.Windows.Forms.DataGridViewEditingControlShowingEventArgs) _
                                 Handles DataGridView1.EditingControlShowing
    With Me.DataGridView1
        If .CurrentCell.ColumnIndex = .Columns("Password").Index Then
            CType(e.Control, TextBox).UseSystemPasswordChar = True
            CType(e.Control, TextBox).PasswordChar = "*"c
        End If
    End With
End Sub

> おはようございます。
> VB.NET2005、クラサバで開発してる若輩者です。
>
> DataGridViewを使用して、ユーザ登録をしたく、
> パスワードの列だけ、入力時、表示時、見かけだけ*表示したいのですが、
> どうしたらいいでしょうか?
>
> TextBoxのPasswordCharみたいなプロパティがあれば最高なんですが、
> 見つけられなかったです。
> お願いします。

- 関連一覧ツリー をクリックするとツリー全体を一括表示します)

古いスレッドにレスはつけられません。