TextBox.UseSystemPasswordChar不保留值

时间:2016-12-20 08:20:39

标签: c# datagridview

我尝试在dataGridView中创建密码列,只需更改每个Control的UseSystemPasswordChar属性,其中ColumnIndex为3:

void grid_EditingControlShowing(object sender, EventArgs e)
{
    if (grid.CurrentCell.ColumnIndex == 3)
    {
        (grid.EditingControl as TextBox).UseSystemPasswordChar = true;
    }
}

但是当细胞失去焦点时,属性值变为" false"再次。 为什么会这样?

1 个答案:

答案 0 :(得分:0)

CurrentCell报告哪个单元格具有焦点。因此,在您的失败案例中,没有单元格具有焦点,因此您的设置永远不会发生。 是否在代码中的其他位置清除了值?