C#-DataGridView设置列不显示

待我称王封你为后i 2021-11-10 15:40 964阅读 0赞

C#-DataGridView设置列不显示, 发现有小BUG,

Form1.Designer.cs文件中会把dataGridVIew1.Columns.AddRange() 部分的代码消失 .

例如: 设置UserID列不显示, 建议,直接在代码文件中在USERID属性代码段后面输入”this.UserID.Visible = false;” 代码,完整的 如代码段2所示 .

代码段1:

//
// dataGridView1
//
this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.UserID,
this.UserName,
this.Password,
this.DeptID,
this.DeptCode,
this.DeptName});
this.dataGridView1.Location = new System.Drawing.Point(16, 30);
this.dataGridView1.Name = “dataGridView1”;

代码段2:

//
// UserID
//
this.UserID.DataPropertyName = “UserID”;
this.UserID.HeaderText = “UserID”;
this.UserID.Name = “UserID”;
this.UserID.Visible = false;

转载于:https://www.cnblogs.com/samrv/p/11089263.html

发表评论

表情:
评论列表 (有 0 条评论,964人围观)

还没有评论,来说两句吧...

相关阅读

    相关 excel中多内容显示

    当excel中某一列显示不全时,我们将光标置于该列的列号之后,待光标呈黑色十字时,双击,此时该列显示完整; 当连续的多列内容显示不全时,此时将多列都选中,将光标置于其中的某列