Exemplo n.º 1
0
        protected void displayOptionsButton_Click(object sender, EventArgs e)
        {
            using (var ccf = new ColumnControlForm())
            {
                ccf.ColumnProperties = _columnSettings.ToDictionary(o => o.Key.HeaderText, o => o.Value);

                if (treeDataGridView.DefaultCellStyle.ForeColor.ToArgb() != SystemColors.WindowText.ToArgb())
                {
                    ccf.DefaultForeColor = treeDataGridView.DefaultCellStyle.ForeColor;
                }
                if (treeDataGridView.DefaultCellStyle.BackColor.ToArgb() != SystemColors.Window.ToArgb())
                {
                    ccf.DefaultBackColor = treeDataGridView.DefaultCellStyle.BackColor;
                }

                if (ccf.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                // update column properties
                foreach (var kvp in ccf.ColumnProperties)
                {
                    _columnSettings[Columns.Single(o => o.HeaderText == kvp.Key)] = kvp.Value;
                }

                setColumnVisibility();

                // update default cell style
                treeDataGridView.ForeColor       = treeDataGridView.DefaultCellStyle.ForeColor = ccf.DefaultForeColor ?? SystemColors.WindowText;
                treeDataGridView.BackgroundColor = treeDataGridView.GridColor = treeDataGridView.DefaultCellStyle.BackColor = ccf.DefaultBackColor ?? SystemColors.Window;

                treeDataGridView.Refresh();
            }
        }
Exemplo n.º 2
0
        protected void displayOptionsButton_Click (object sender, EventArgs e)
        {
            using (var ccf = new ColumnControlForm())
            {
                ccf.ColumnProperties = _columnSettings.ToDictionary(o => o.Key.HeaderText, o => o.Value);

                if (treeDataGridView.DefaultCellStyle.ForeColor.ToArgb() != SystemColors.WindowText.ToArgb())
                    ccf.DefaultForeColor = treeDataGridView.DefaultCellStyle.ForeColor;
                if (treeDataGridView.DefaultCellStyle.BackColor.ToArgb() != SystemColors.Window.ToArgb())
                    ccf.DefaultBackColor = treeDataGridView.DefaultCellStyle.BackColor;

                if (ccf.ShowDialog() != DialogResult.OK)
                    return;

                // update column properties
                foreach (var kvp in ccf.ColumnProperties)
                    _columnSettings[Columns.Single(o => o.HeaderText == kvp.Key)] = kvp.Value;

                setColumnVisibility();

                // update default cell style
                treeDataGridView.ForeColor = treeDataGridView.DefaultCellStyle.ForeColor = ccf.DefaultForeColor ?? SystemColors.WindowText;
                treeDataGridView.BackgroundColor = treeDataGridView.DefaultCellStyle.BackColor = ccf.DefaultBackColor ?? SystemColors.Window;

                treeDataGridView.Refresh();
            }
        }