fork download
  1. public Form1() {
  2. InitializeComponent();
  3.  
  4. var table = new DataTable();
  5.  
  6. for(int i = 0; i < 3; i++) {
  7. table.Columns.Add();
  8. }
  9.  
  10. for(int i = 0; i < 10; i++) {
  11. table.Rows.Add(table.NewRow());
  12. }
  13.  
  14. var grid = new DataGridView();
  15. grid.Height = 500;
  16. grid.RowHeadersVisible = false;
  17. grid.ColumnHeadersVisible = false;
  18. grid.AllowUserToAddRows = false;
  19. grid.Parent = this;
  20.  
  21. var view = new DataView(table);
  22. var bs = new BindingSource();
  23.  
  24. bs.DataSource = view;
  25. grid.DataSource = bs;
  26.  
  27. grid.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.None;
  28. foreach(DataGridViewRow row in grid.Rows) {
  29. row.Height = grid.Height / grid.Rows.Count;
  30. }
  31.  
  32. int amari = grid.Height - ((grid.Height / grid.Rows.Count) * grid.Rows.Count);
  33. for(int i = 0; i < amari; i++) {
  34. grid.Rows[i].Height += 1;
  35. }
  36.  
  37. }
  38.  
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty