开发者

Hide columns in a DataGridView

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜