private void PopulateGrid()
        {
            _populating = true;

            DataGrid.Rows.Clear();

            // Excel-ify! Hopefully we won't need more than 26 columns. :P
            DataGrid.Columns.Clear();
            for (var i = 0; i < _loadedData.ColumnTypes.Count; i++)
            {
                var str    = $"{i} ({_loadedData.ColumnTypes[i]})";
                var colIdx = DataGrid.Columns.Add(str, str);
                DataGrid.Columns[colIdx].SortMode = DataGridViewColumnSortMode.NotSortable;
            }

            foreach (var row in _loadedData.Data)
            {
                var rowIdx  = DataGrid.Rows.Add();
                var dataRow = DataGrid.Rows[rowIdx];

                var cellIdx = 0;
                foreach (var cell in row)
                {
                    dataRow.Cells[cellIdx++].Value = cell;
                }
            }

            DataGrid.AutoResizeColumns();
            _populating = false;

            UpdateRowColumn();
        }
        public void ApplyDataTale(DataTable table)
        {
            bs.DataSource       = table;
            DataGrid.DataSource = bs;
            DataGrid.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);

            this.toolStripLabel1.Text = $"{DataGrid.Rows.Count} rows";
        }
        private void RefreshDataAdapter()
        {
            if (adapter == null)
            {
                return;
            }

            this.adapter.FillSchema(adapterDataSet, SchemaType.Source);
            this.adapter.Fill(adapterDataSet);

            bs.DataSource       = adapterDataSet.Tables[0];
            DataGrid.DataSource = bs;
            DataGrid.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);

            this.toolStripLabel1.Text = $"{DataGrid.Rows.Count} rows";
        }
Beispiel #4
0
 public void AutoResizeGridColumns()
 {
     DataGrid.AutoResizeColumns();
 }
 private void noneToolStripMenuItem_Click(object sender, EventArgs e)
 {
     DataGrid.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.None);
 }
 private void displayedCellsToolStripMenuItem_Click(object sender, EventArgs e)
 {
     DataGrid.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.DisplayedCells);
 }
 private void allCellsExceptHeaderToolStripMenuItem_Click(object sender, EventArgs e)
 {
     DataGrid.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCellsExceptHeader);
 }