I want to make my row to auto resize depending on screen size.
When I do this for column it really works:
grid.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
But when I want to do same thing for row. I don’t have fill option.
I only have like
grid.AutoSizeRowsMode = System.Windows.Forms.DataGridViewAutoSizeRowsMode.AllCells;
How can I make my rows to fill my screen depending on it’s size?
You can use the
AutoResizeRowmethod.Per MSDN:
There’s also a MSDN sample here.
You may want to look in to the
RowTemplateproperty namedHeight. You can do your calculation as to when the screen size changesEDIT:
You can put this in a resizing event, such as
Form_ResizeEnd. YMMV on how the grid may perform with a large number of rows.I believe you can use
System.Windows.Form.Screensclass, specificallyScreens.PrimaryScreen.Bounds.Heightif you want the primary screen’s height. It’s up to you to see what kind of size you want to maintain.