Beispiel #1
0
        public void SetColumnizer(ILogLineColumnizer columnizer, DataGridView gridView)
        {
            int rowCount = gridView.RowCount;
            int currLine = gridView.CurrentCellAddress.Y;
            int currFirstLine = gridView.FirstDisplayedScrollingRowIndex;

            gridView.Columns.Clear();

            DataGridViewTextBoxColumn markerColumn = new DataGridViewTextBoxColumn();
            markerColumn.HeaderText = "";
            markerColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.NotSet;
            markerColumn.Resizable = DataGridViewTriState.False;
            markerColumn.DividerWidth = 1;
            markerColumn.ReadOnly = true;
            markerColumn.HeaderCell.ContextMenuStrip = columnContextMenuStrip;
            gridView.Columns.Add(markerColumn);

            DataGridViewTextBoxColumn lineNumberColumn = new DataGridViewTextBoxColumn();
            lineNumberColumn.HeaderText = "Line";
            lineNumberColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.NotSet;
            lineNumberColumn.Resizable = DataGridViewTriState.NotSet;
            lineNumberColumn.DividerWidth = 1;
            lineNumberColumn.ReadOnly = true;
            lineNumberColumn.HeaderCell.ContextMenuStrip = columnContextMenuStrip;
            gridView.Columns.Add(lineNumberColumn);

            foreach (string colName in columnizer.GetColumnNames())
            {
                DataGridViewColumn titleColumn = new LogTextColumn();
                titleColumn.HeaderText = colName;
                titleColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.NotSet;
                titleColumn.Resizable = DataGridViewTriState.NotSet;
                titleColumn.DividerWidth = 1;
                titleColumn.HeaderCell.ContextMenuStrip = columnContextMenuStrip;
                gridView.Columns.Add(titleColumn);
            }

            columnNamesLabel.Text = CalculateColumnNames(_filterParams);

            gridView.RowCount = rowCount;
            if (currLine != -1)
            {
                gridView.CurrentCell = gridView.Rows[currLine].Cells[0];
            }
            if (currFirstLine != -1)
            {
                gridView.FirstDisplayedScrollingRowIndex = currFirstLine;
            }
            gridView.Refresh();
            AutoResizeColumns(gridView);
            ApplyFrozenState(gridView);
        }
Beispiel #2
0
        public static void SetColumnizer(ILogLineColumnizer columnizer, DataGridView gridView)
        {
            int rowCount = gridView.RowCount;
            int currLine = gridView.CurrentCellAddress.Y;
            int currFirstLine = gridView.FirstDisplayedScrollingRowIndex;

            try
            {
                gridView.Columns.Clear();
            }
            catch (ArgumentOutOfRangeException ae)
            {
                // Occures sometimes on empty gridViews (no lines) if bookmark window was closed and re-opened in floating mode.
                // Don't know why.
                Logger.logError(ae.Message);
            }

            DataGridViewTextBoxColumn markerColumn = new DataGridViewTextBoxColumn();
            markerColumn.HeaderText = "";
            markerColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.NotSet;
            markerColumn.Resizable = DataGridViewTriState.False;
            markerColumn.DividerWidth = 1;
            markerColumn.ReadOnly = true;
            // markerColumn.HeaderCell.ContextMenuStrip = this.columnContextMenuStrip;
            gridView.Columns.Add(markerColumn);

            DataGridViewTextBoxColumn lineNumberColumn = new DataGridViewTextBoxColumn();
            lineNumberColumn.HeaderText = "Line";
            lineNumberColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.NotSet;
            lineNumberColumn.Resizable = DataGridViewTriState.NotSet;
            lineNumberColumn.DividerWidth = 1;
            lineNumberColumn.ReadOnly = true;
            // lineNumberColumn.HeaderCell.ContextMenuStrip = this.columnContextMenuStrip;
            gridView.Columns.Add(lineNumberColumn);

            foreach (string colName in columnizer.GetColumnNames())
            {
                DataGridViewColumn titleColumn = new LogTextColumn();
                titleColumn.HeaderText = colName;
                titleColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.NotSet;
                titleColumn.Resizable = DataGridViewTriState.NotSet;
                titleColumn.DividerWidth = 1;
                //titleColumn.HeaderCell.ContextMenuStrip = this.columnContextMenuStrip;
                gridView.Columns.Add(titleColumn);
            }

            gridView.RowCount = rowCount;
            if (currLine != -1)
                gridView.CurrentCell = gridView.Rows[currLine].Cells[0];
            if (currFirstLine != -1)
                gridView.FirstDisplayedScrollingRowIndex = currFirstLine;
            //gridView.Refresh();
            //AutoResizeColumns(gridView);
        }