Imports System.Windows.Forms Imports System.Drawing Public Class Form1 Private WithEvents dgv As New DataGridView() ''' <summary>パスワード表示するセル座標なら True を返す</summary> Private Function IsPasswordCell(ByVal row As Integer, ByVal column As Integer) As Boolean 'この部分は、実際の判定条件に応じて変更してください。 Return column = 1 End Function ''' <summary>パスワード表示するセル座標なら True を返す</summary> Private Function IsPasswordCell(ByVal address As Point) As Boolean Return IsPasswordCell(address.Y, address.X) End Function Private Sub Form1_Load() Handles Me.Load dgv.Dock = DockStyle.Fill Controls.Add(dgv) dgv.AllowUserToAddRows = False dgv.ColumnCount = 5 dgv.RowCount = 20 dgv.EditMode = DataGridViewEditMode.EditOnEnter End Sub Private Sub dgv_EditingControlShowing(ByVal sender As Object, ByVal e _ As DataGridViewEditingControlShowingEventArgs) Handles dgv.EditingControlShowing Dim t As TextBox = TryCast(e.Control, TextBox) If t IsNot Nothing Then '入力時のパスワード隠し t.UseSystemPasswordChar = IsPasswordCell(dgv.CurrentCellAddress) End If End Sub Private Sub dgv_CellFormatting(ByVal sender As Object, ByVal e As _ DataGridViewCellFormattingEventArgs) Handles dgv.CellFormatting If IsPasswordCell(e.RowIndex, e.ColumnIndex) Then '表示時のパスワード隠し e.Value = StrDup(Len(e.Value), "*"c) End If End Sub 'Private Sub dgv_CellEnter(ByVal sender As DataGridView, ByVal e As DataGridViewCellEventArgs) Handles dgv.CellEnter ' Text = CStr(sender(e.ColumnIndex, e.RowIndex).Value) 'End Sub End Class