【发布时间】:2011-02-13 17:10:44
【问题描述】:
我正在创建一个应用程序,用户在该应用程序中选择文件并提供打开该文件的凭据。为此,我在 gridview 中创建了三列。
用户在密码栏中输入密码。
我想显示 * 来代替字符,例如我们可以创建密码类型的文本框。
我在GridView_CellClick 事件上尝试过这段代码:
if (GridView.Columns[e.ColumnIndex].HeaderText == "Password")
{
txtPassword[e.RowIndex] = new TextBox();
txtPassword[e.RowIndex].Name = "txtPassword"+e.RowIndex;
txtPassword[e.RowIndex].PasswordChar = '*';
txtPassword[e.RowIndex].Visible = true;
txtPassword[e.RowIndex].TextChanged += new
if (GridView.CurrentCell.Value == null)
txtPassword[e.RowIndex].Text = "";
else
txtPassword[e.RowIndex].Text = GridView.CurrentCell.Value.ToString();
txtPassword[e.RowIndex].Location = GridView.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex + 1, false).Location;
txtPassword[e.RowIndex].Size = GridView.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex + 1, false).Size;
txtPassword[e.RowIndex].Visible = true;
txtPassword[e.RowIndex].Focus();
}
但在上述解决方案中显示字符。
我该如何解决这个问题?
【问题讨论】:
标签: c# winforms gridview passwords