private void FillGrid() { if (treeView.SelectedNode == null || treeView.SelectedNode.Tag == null) { return; } Cursor = Cursors.WaitCursor; var filteredText = chkFilter.Checked && txtFind.Text.Trim() != "" ? txtFind.Text : ""; dataGridView.Columns.Clear(); dataGridView.Rows.Clear(); var currentSchema = treeView.SelectedNode.Tag as Schema; var nodeView = new NodeView(filteredText); nodeView.BuildView(currentSchema, rootNode, nodeViewOption); var columns = nodeView.GetColumns(nodeViewOption); dataGridView.ColumnCount = columns.Count; for (var iColumn = 0; iColumn < columns.Count; ++iColumn) { var column = columns[iColumn]; dataGridView.Columns[iColumn].Name = column; } var rows = nodeView.GetRows(nodeViewOption); foreach (var row in rows) { if (row.Count == 0) { continue; } dataGridView.Rows.Add(row.ToArray()); } dataGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells); for (var iColumn = 0; iColumn < dataGridView.ColumnCount; ++iColumn) { var column = dataGridView.Columns[iColumn]; column.SortMode = DataGridViewColumnSortMode.NotSortable; } if (!nodeView.OnlyOne) { var text = treeView.SelectedNode.Text; var pos = text.LastIndexOf('['); if (pos == -1) { text += $" [{dataGridView.RowCount}]"; treeView.SelectedNode.Text = text; } } SetGridColor(); Cursor = Cursors.Default; }