防止DataTable中的一些DataColumn绑定到DataGridView [英] Prevent some DataColumns in a DataTable from being bound to DataGridView

查看:111
本文介绍了防止DataTable中的一些DataColumn绑定到DataGridView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有什么办法可以指定DataTable中的某些列不会自动绑定到DataGridView,DataGridView的DataSource属性为DataTable。 p>例如,如果我有一个数据表的列为Id,名称,那么我可以指定Id列不会显示在DataGridView?我知道在DataGridView被绑定后,我可以设置一些Visible属性,但是可以在DataTable / DataColumn中指定吗?

解决方案

最好设置列及其绑定。



如何在Windows窗体中添加和删除列表DataGridView控件使用Designer



否则,您可以删除不需要的列:



如何:隐藏Windows窗体中的列DataGridView控件使用设计器


Is there any way I can specify that some columns in a DataTable will not be automatically bound to a DataGridView when I set the DataSource property of the DataGridView to the DataTable.

For example, if I have a DataTable with columns as "Id, Name" then can I specify that Id column will not be shown in DataGridView? I know I can set some Visible property in DataGridView after it is bound, but can I specify in the DataTable/DataColumn itself?

解决方案

It's best to setup the columns and their bindings.

How to: Add and Remove Columns in the Windows Forms DataGridView Control Using the Designer

Otherwise, you can remove the unwanted columns:

How to: Hide Columns in the Windows Forms DataGridView Control Using the Designer

这篇关于防止DataTable中的一些DataColumn绑定到DataGridView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆