开发者

Data column resize mode setting in DataGridView (c#)

I have a DataGridView containing two columns. What I want columns to behave is, column A has a minimum width and nothing else. Column B should take up whatever space left. Users can resize column A's width freely and column B always takes up whatever space left.

I was thinking to set column B's auto size mode to fill but this doesn't allow users to resize column A's width. How can I set the two c开发者_如何学Goolumns' resize mode to achieve the above behaviour? Thanks.


What you need to do is set the DataGridView's AutoSizeColumnMode property to "Fill". Then, set the MinimumWidth and Width properties on Column A to whatever your desired width is.

Assuming you only have 2 columns, this means Column A will be whatever width you want it to be, and the rest of the grid's width will be filled by Column B.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜