单击时在 DataGridView 中显示密码数据

Showing password data in DataGridView when clicked

我只是 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 吗?

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

然后使用此代码

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