Parameter DataGridView Height of the line in the code and disable manual resizing

advertisements

In my grid I had following line of code which disabled user's manual resizing:

dgvTruckAvail.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells;

Now I needed to set column height in code and it didn't work (see DataGridView setting row height doesn't work)

I figured that it was this line of code that caused non-sizing issue. However, now I need to figure out how to

  1. Size rows in code

and

  1. Prevent user sizing rows themselves

Any pointers?


Set:

dgvTruckAvail.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.None;
dgvTruckAvail.AllowUserToResizeRows = false;

This will disable row autosizing and manual row resizing. To set the row height you can use the Height and MinimumHeight properties of the RowTemplate.