为了在 PropertyGrid 中将密码显示为‘*’需要使用 PasswordPropertyText 属性。

 

示例如下:

class Settings {
    [CategoryAttribute("Login"), DisplayName("User Name"), DescriptionAttribute("Login Name")]
    public string Username { get; set; }

    [CategoryAttribute("Login"), DisplayName("Password"), DescriptionAttribute("Login Password")]
    [PasswordPropertyText(true)]
    public string Password { get; set; }
}

 

private void MainForm_Load(object sender, EventArgs e) {
    propertyGrid.SelectedObject = new Settings();
    propertyGrid.PropertySort = PropertySort.NoSort;
}

posted on 2012-06-05 14:52  YUVU  阅读(427)  评论(0编辑  收藏  举报