Ejemplo n.º 1
0
        private void queryBuilder1_QueryElementControlCreated(QueryElement queryElement, IQueryElementControl queryElementControl)
        {
            if (queryElementControl is IQueryColumnListControl)
            {
                IQueryColumnListControl queryColumnListControl = (IQueryColumnListControl)queryElementControl;
                DataGridView            dataGridView           = (DataGridView)queryColumnListControl.DataGrid;

                _customColumn?.Dispose();

                // Create custom column
                _customColumn = new DataGridViewCheckBoxColumn
                {
                    Name               = "CustomColumn",
                    HeaderText         = "Custom Column",
                    Width              = 100,
                    FlatStyle          = FlatStyle.Standard,
                    ValueType          = typeof(CheckState),
                    TrueValue          = CheckState.Checked,
                    FalseValue         = CheckState.Unchecked,
                    IndeterminateValue = CheckState.Indeterminate
                };

                _customColumn.HeaderCell.Style.Font = new Font("Tahoma", 8, FontStyle.Bold);

                // Insert custom column to specified position
                dataGridView.Columns.Insert(2, _customColumn);

                // Handle required events
                dataGridView.CellBeginEdit   += DataGridView_CellBeginEdit;
                dataGridView.CellValueNeeded += DataGridView_CellValueNeeded;
                dataGridView.CellValuePushed += DataGridView_CellValuePushed;
            }
        }
        // Populate view of character sets.
        private void PopulateCharacterSetView(IEnumerable <CharacterSet> characterSets)
        {
            // Add character sets to control.
            bool          exceptionThrown = true;
            BindingSource newBinding      = new BindingSource();

            try
            {
                foreach (CharacterSet characterSet in characterSets)
                {
                    newBinding.Add(characterSet);
                }
                this.dgvCharacterSets.DataSource = newBinding;
                exceptionThrown = false;
            }
            finally
            {
                // Just in case the .Add throws an exception.
                if (exceptionThrown)
                {
                    newBinding.Dispose();
                }
            }

            // Add extra column to control.
            exceptionThrown = true;
            var columnCheck = new DataGridViewCheckBoxColumn();

            try
            {
                columnCheck.Name       = COLUMN_NAME_ALLOWED;
                columnCheck.HeaderText = COLUMN_NAME_ALLOWED + "?";
                this.dgvCharacterSets.Columns.Add(columnCheck);
                exceptionThrown = false;
            }
            finally
            {
                // Just in case the .Add throws an exception.
                if (exceptionThrown)
                {
                    columnCheck.Dispose();
                }
            }

            // Set flag for every allowed character set.
            foreach (DataGridViewRow row in this.dgvCharacterSets.Rows)
            {
                row.Cells[COLUMN_NAME_ALLOWED].Value = true;
            }
            // If only one allowed character set, make sure it isn't removed!
            this.AtLeastOneCharacterSetAllowed();

            this.dgvCharacterSets.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;
            this.dgvCharacterSets.AutoResizeColumns();
        }
Ejemplo n.º 3
0
        private void AddComboBoxColumns()
        {
            DataGridViewCheckBoxColumn checkboxColumn = new DataGridViewCheckBoxColumn();

            checkboxColumn.HeaderText       = clsTranslate.TranslateString("Status");
            checkboxColumn.DataPropertyName = "Status";
            checkboxColumn.Name             = "Status";
            checkboxColumn.Width            = 50;
            DBGrid.Columns.RemoveAt(2);
            DBGrid.Columns.Insert(2, checkboxColumn);
            checkboxColumn.Dispose();
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 列追加(チェックボックス)
        /// </summary>
        /// <param name="dgv">DataGridViewオブジェクト</param>
        /// <param name="HeaderText">表示タイトル</param>
        /// <param name="DataPropertyName">元データタイトル</param>
        /// <param name="argTrueValue">Trueとする値</param>
        /// <param name="argThreeState"></param>
        static public void AddCol_ChkBox(DataGridView dgv, string HeaderText, string ColName, string DataPropertyName,
                                         object argTrueValue, object argFalseValue, bool argThreeState, bool readOnly)
        {
            DataGridViewCheckBoxColumn col = new DataGridViewCheckBoxColumn();

            col.DataPropertyName = DataPropertyName;
            col.HeaderText       = HeaderText;
            col.Name             = ColName;
            col.TrueValue        = argTrueValue;
            col.FalseValue       = argFalseValue;
            col.ThreeState       = argThreeState;
            col.ReadOnly         = readOnly;
            col.SortMode         = DataGridViewColumnSortMode.NotSortable;
            dgv.Columns.Add(col);
            col.Dispose();
        }