如何在DataGridView中对列进行密码填充

时间:2016-04-13 15:11:54

标签: c# datagridview password-protection

我正在尝试在表中加载时对char列进行密码。

以下代码加载表格。

//Fills out Student table
private void loadStudentTable()
{
    SqlConnection conn2 = new SqlConnection(@"Data Source=(LocalDB)\v11.0; AttachDbFilename=C:\Users\Donald\Documents\Visual Studio 2013\Projects\DesktopApplication\DesktopApplication\Student_CB.mdf ;Integrated Security=True");
    conn2.Open();

    try
    {
        SqlCommand cmdDatabase2 = new SqlCommand("Select * from Student", conn2);
        SqlDataAdapter sda2 = new SqlDataAdapter();
        sda2.SelectCommand = cmdDatabase2;
        DataTable dbdataset2 = new DataTable();
        sda2.Fill(dbdataset2);
        BindingSource bSource2 = new BindingSource();
        bSource2.DataSource = dbdataset2;
        studentGridView.DataSource = bSource2;
        sda2.Update(dbdataset2);
        studentGridView.Columns[0].Width = 92;
        studentGridView.Columns[1].Width = 200;
        studentGridView.Columns[2].Width = 180;
        studentGridView.Columns[3].Width = 180;
        studentGridView.Columns[4].Width = 170;
        studentGridView.Columns[5].Width = 170;
        studentGridView.Columns[6].Width = 130;                        
    }
    catch (Exception ex)
    {
        MessageBox.Show(ex.Message);
    }

    conn2.Close();
}

我正在尝试在studentGridView.Columns[5].Width = 170;列中输入密码。

任何帮助或想法?

1 个答案:

答案 0 :(得分:4)

您需要Release build trunk.965997 (965997) - 155mc13bcf03t - 2016-04-13T14:46:44.823+0000 这样的https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach事件

DataGridView