开发者

Hide columns in a DataGridView

开发者 https://www.devze.com 2023-01-21 03:16 出处:网络
Let\'s say I have a table like so: Friend ------ Id int not null FriendName nvarchar(50) not null Phone nvarchar(50) null

Let's say I have a table like so:

Friend
------
Id int not null
FriendName nvarchar(50) not null
Phone nvarchar(50) null

If I bind my DataGridView control in a Windows Forms application to an ObjectQuery<Friend>/ObjectSet<Friend>/IList<Friend> returned from an ObjectContext like so:

MyFriendsGridView.DataSource = _context.Friends.ToList();

All the columns that are in the Friend table appe开发者_JAVA百科ar in the grid. Suppose I want the Id column not to show up in the grid, how do I do that?

Do I simply hide the column in the grid's properties by setting the column's visibility to false? Is there a more elegant solution?


Setting column's visible property to false is the elegant solution as far as I know.

0

精彩评论

暂无评论...
验证码 换一张
取 消