[英]Add column into datagridview taken from database
I'm showing data from database table into datagridview each column has a checkbox for example column named "Tel" has a check box "checkBox_Tel" 我正在将数据从数据库表显示到datagridview中,每列都有一个复选框,例如名为“ Tel”的列有一个复选框“ checkBox_Tel”
if (!checkBox_Tel.Checked)
{
dg.Columns.Remove("Tel");
}
when the user uncheck one , the column related to this check box is removed from the dgv 当用户取消选中一个时,与此复选框相关的列将从dgv中删除
but i want to return that column when the user recheck it how can i do that? 但是我想在用户重新检查它时返回该列,我该怎么做?
If your intent is just to hide the column and then restore its visibility then 如果您的目的只是隐藏列,然后恢复其可见性,则
dg.Columns("Tel").Visible = checkBox_Tel.Checked
Use this property to hide a column from view while keeping the column in the DataGridView.
使用此属性可将列隐藏在视图中,同时将列保留在DataGridView中。 To completely remove a column, use the DataGridViewColumnCollection.Remove method.
若要完全删除列,请使用DataGridViewColumnCollection.Remove方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.