Mr_Green
Mr_Green

Reputation: 41832

How to make a datagridview columns fixed

I am new to .net. I will try my best to explain the problem. As you can see in the images the columns are resizing which i dont want to happen. I tried giving readonly property but this doesnt work.

enter image description here

I dont want this to happen

enter image description here

Please also give some suggestions to prevent user from changing the column width.

well this may be a very small issue.

Please help
Thanks in Advance.

Upvotes: 0

Views: 3465

Answers (1)

Henk Holterman
Henk Holterman

Reputation: 273219

There's a whole set of properties to regulate this exactly.

In code:

dataGridView1.AllowUserToResizeColumns = false;

dataGridView1.Columns[0].AutoSizeMode = DataGridViewAutoSizeColumnMode.None;

You will be able to find them in the Properties Window(s) as well. Note the Columns (Collection) [...] item.

Upvotes: 2

Related Questions