Skip to main content
gamedev.net
🔒 Locked

datagridview question

Started by JohnnyCode Apr 8, 2009 at 12:59 PM 0 replies 450+ views
Original Post
JohnnyCode
JohnnyCode
hello, I have a DataGridView control in my app, and columns in it set to my generic width. The problem is that when I set AutoSizeMode property of all columns to DataGridViewAutoSizeColumnMode.Fill My all columns are resized, How could I stop this behaviour? I mean to not resize my columns after AutoSizeMode property changes. Also, if I have DataGridViewAutoSizeColumnMode.Fill enabled it couses that I cannot adjust column width, that is when I assign a number to Width property of a column, the width of a column is different form the one I assigned, also for some columns this property does not change even when I call column.Width= 100, the width remains 5. Thanks in advance
Moe
Moe
I'm not sure I understand your question. What exactly is it that you are trying to do?

From my understanding, when you set the AutoSizeMode property, it will size your columns depending on the mode selected. Setting it will cause your columns to be resized according to what you set it to. If you don't want your columns to be resized, don't set it. The DataGridViewAutoSizeColumnMode.Fill setting will cause the columns to be sized so that all the visible columns will appear on the DataGridView. So, for example, if you have a DataGridView that is 600 pixels wide, and you have three visible columns, each column will be sized to 200 pixels wide. I believe setting it to .Fill will also disable column resizing (since it doesn't make much sense to allow resizing when things will automatically be resized anyway).

I'm guessing what you probaby want to do is have your first few columns set to be the width of the contents (.AllCells) and have your last column width set to .Fill.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.