public Form1() {
InitializeComponent();
var table = new DataTable();
for(int i = 0; i < 3; i++) {
table.Columns.Add();
}
for(int i = 0; i < 10; i++) {
table.Rows.Add(table.NewRow());
}
var grid = new DataGridView();
grid.Height = 500;
grid.RowHeadersVisible = false;
grid.ColumnHeadersVisible = false;
grid.AllowUserToAddRows = false;
grid.Parent = this;
var view = new DataView(table);
var bs = new BindingSource();
bs.DataSource = view;
grid.DataSource = bs;
grid.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.None;
foreach(DataGridViewRow row in grid.Rows) {
row.Height = grid.Height / grid.Rows.Count;
}
int amari = grid.Height - ((grid.Height / grid.Rows.Count) * grid.Rows.Count);
for(int i = 0; i < amari; i++) {
grid.Rows[i].Height += 1;
}
}
ICAgICAgICBwdWJsaWMgRm9ybTEoKSB7CiAgICAgICAgICAgIEluaXRpYWxpemVDb21wb25lbnQoKTsKCiAgICAgICAgICAgIHZhciB0YWJsZSA9IG5ldyBEYXRhVGFibGUoKTsKCiAgICAgICAgICAgIGZvcihpbnQgaSA9IDA7IGkgPCAzOyBpKyspIHsKICAgICAgICAgICAgICAgIHRhYmxlLkNvbHVtbnMuQWRkKCk7CiAgICAgICAgICAgIH0KCiAgICAgICAgICAgIGZvcihpbnQgaSA9IDA7IGkgPCAxMDsgaSsrKSB7CiAgICAgICAgICAgICAgICB0YWJsZS5Sb3dzLkFkZCh0YWJsZS5OZXdSb3coKSk7CiAgICAgICAgICAgIH0KCiAgICAgICAgICAgIHZhciBncmlkID0gbmV3IERhdGFHcmlkVmlldygpOwogICAgICAgICAgICBncmlkLkhlaWdodCA9IDUwMDsKICAgICAgICAgICAgZ3JpZC5Sb3dIZWFkZXJzVmlzaWJsZSA9IGZhbHNlOwogICAgICAgICAgICBncmlkLkNvbHVtbkhlYWRlcnNWaXNpYmxlID0gZmFsc2U7CiAgICAgICAgICAgIGdyaWQuQWxsb3dVc2VyVG9BZGRSb3dzID0gZmFsc2U7CiAgICAgICAgICAgIGdyaWQuUGFyZW50ID0gdGhpczsKCiAgICAgICAgICAgIHZhciB2aWV3ID0gbmV3IERhdGFWaWV3KHRhYmxlKTsKICAgICAgICAgICAgdmFyIGJzID0gbmV3IEJpbmRpbmdTb3VyY2UoKTsKCiAgICAgICAgICAgIGJzLkRhdGFTb3VyY2UgPSB2aWV3OwogICAgICAgICAgICBncmlkLkRhdGFTb3VyY2UgPSBiczsKCiAgICAgICAgICAgIGdyaWQuQXV0b1NpemVSb3dzTW9kZSA9IERhdGFHcmlkVmlld0F1dG9TaXplUm93c01vZGUuTm9uZTsKICAgICAgICAgICAgZm9yZWFjaChEYXRhR3JpZFZpZXdSb3cgcm93IGluIGdyaWQuUm93cykgewogICAgICAgICAgICAgICAgcm93LkhlaWdodCA9IGdyaWQuSGVpZ2h0IC8gZ3JpZC5Sb3dzLkNvdW50OwogICAgICAgICAgICB9CgogICAgICAgICAgICBpbnQgYW1hcmkgPSBncmlkLkhlaWdodCAtICgoZ3JpZC5IZWlnaHQgLyBncmlkLlJvd3MuQ291bnQpICogZ3JpZC5Sb3dzLkNvdW50KTsKICAgICAgICAgICAgZm9yKGludCBpID0gMDsgaSA8IGFtYXJpOyBpKyspIHsKICAgICAgICAgICAgICAgIGdyaWQuUm93c1tpXS5IZWlnaHQgKz0gMTsKICAgICAgICAgICAgfQoKICAgICAgICB9ICAgCg==