0

i'm just new to c# and visual studio

so i figured how to mask the password in my datagridview with this

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);

        }
    }

Now i wanted to show the password again when i click on the cell, i figured it would be on dataGridView_CellClick event but i can't figure how to make it show up again. do i assign it to e.Value again?

Ezz Redfox
  • 89
  • 1
  • 9
  • [This would be a gud one for you](https://stackoverflow.com/questions/31400177/masking-password-column-in-datagridview) – Syed Muhammad Munis Ali Jan 20 '18 at 09:14
  • The cells should not be editable and will only be read only, so i can't use the UseSystemPasswordChar = false; the purpose of this is only for the admin to view a specific password on the list and not showing all. – Ezz Redfox Jan 20 '18 at 10:09

1 Answers1

0

use a textbox by design in that column of gridview and from source add a checkbox too !

then use this code

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