Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- dataGridView.Columns.Clear( );
- dataGridView.ColumnCount = (int)matrix.Width;
- float rowsHeight = (float)dataGridView.Height / matrix.Height;
- float cellsWidth = (float)dataGridView.Width / matrix.Width;
- for (uint rowIndex = 0u; rowIndex < matrix.Height; rowIndex++) {
- DataGridViewRow row = new DataGridViewRow( );
- row.CreateCells(dataGridView, matrix.Width);
- for (uint columnIndex = 0u; columnIndex < matrix.Width; columnIndex++) {
- bool value = matrix[columnIndex, rowIndex];
- var cell = row.Cells[(int)columnIndex];
- cell.Value = value ? 1 : 0;
- cell.Style.BackColor = //columnIndex >= k ? Color.FromArgb(192, 192, 192) :
- value ? Color.FromArgb(60, 192, 60) : Color.FromArgb(192, 60, 60);
- cell.Style.ForeColor = Color.Black;
- cell.Style.Font = new Font("Consolas", 9);
- }
- dataGridView.Rows.Add(row);
- row.Height = (int)(rowIndex * rowsHeight) - (int)(((int)rowIndex - 1) * rowsHeight);
- }
- for (int columnIndex = 0; columnIndex < dataGridView.ColumnCount; columnIndex++) {
- var column = dataGridView.Columns[columnIndex];
- column.SortMode = DataGridViewColumnSortMode.NotSortable;
- column.Width = (int)(columnIndex * cellsWidth) - (int)((columnIndex - 1) * cellsWidth);
- }
- dataGridView.ClearSelection( );
Advertisement
Add Comment
Please, Sign In to add comment