C# 从 GridView 中删除列
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1215996/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 13:46:02 来源:igfitidea点击:
Delete Columns from GridView
提问by
I have a GridView with a couple of columns that I do not want to be exported to PDF (through iTextSharp).
我有一个带有几列的 GridView,我不想将它们导出为 PDF(通过 iTextSharp)。
How can I hide the columns I don't want exported before I export the data?
在导出数据之前,如何隐藏不想导出的列?
回答by Max
Before exporting the data, do something like:
在导出数据之前,请执行以下操作:
myGridView.columns.RemoveAt(index); //Index is the index of the column you want to remove
myGridView.Databind();
回答by mustafabar
or try
或尝试
dataGridView1.Columns[index].Visible = false; // the index of the column to be hidden