【问题标题】:Showing password data in DataGridView when clicked单击时在 DataGridView 中显示密码数据
【发布时间】:2018-01-20 08:49:33
【问题描述】:

我只是 C# 和 Visual Studio 的新手

所以我想出了如何用这个来屏蔽我的datagridview中的密码

private void dataGridView_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
    {
        if (e.ColumnIndex == 5  && e.Value != null)
        {
            dataGridView.Rows[e.RowIndex].Tag = e.Value;
            e.Value = new String('\u25CF', e.Value.ToString().Length);

        }
    }

现在我想在单击单元格时再次显示密码,我认为它会在 dataGridView_CellClick 事件中,但我不知道如何让它再次显示。我要再次将它分配给 e.Value 吗?

【问题讨论】:

  • 这些单元格不应该是可编辑的,只能是只读的,所以我不能使用 UseSystemPasswordChar = false;这样做的目的只是让管理员查看列表中的特定密码,而不是全部显示。

标签: c# datagridview passwords masking


【解决方案1】:

在gridview的该列中设计使用文本框,并从源代码中添加一个复选框!

然后使用此代码

private void FromSourceAddedCheckBox_CheckedChanged(object sender, EventArgs e)
{
    if (FromSourceAddedCheckBox.Checked == true)
    {
        GridviewTextboxID.UseSystemPasswordChar = true;
    }
    else 
    {
        GridviewTextboxID.UseSystemPasswordChar = false;
    }
}

【讨论】:

  • 它在 DataGridViewTextBoxColumn 中,我怎样才能让它只作为 TextBox?
  • 你可以去gridview源代码,你会找到你的每一列然后你可以做任何你想做的事情
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2020-09-24
  • 2017-02-14
  • 1970-01-01
  • 2014-01-07
  • 1970-01-01
  • 2016-11-03
  • 2017-05-12
相关资源
最近更新 更多