Пример #1
0
        private void AddCheckAllCheckbox()
        {
            KryptonDataGridViewCheckBoxColumn checkBoxColumn = (KryptonDataGridViewCheckBoxColumn)dgvCounties.Columns[0];

            checkBoxColumn.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
            //Create checkbox control
            KryptonCheckBox checkboxHeader = new KryptonCheckBox();

            checkboxHeader.Checked = false;
            checkboxHeader.Name    = "checkboxHeader";
            checkboxHeader.Text    = "";
            checkboxHeader.Size    = new Size(15, 15);
            //Position it and center it inside its cell
            Rectangle rect = dgvCounties.GetCellDisplayRectangle(0, -1, true);

            rect.X = rect.Location.X + (rect.Width / 2) - checkboxHeader.Width / 2;
            rect.Y = rect.Location.Y + rect.Height / 2 - checkboxHeader.Height / 2;
            checkboxHeader.Location = rect.Location;
            //Handle checked changed event and add to grid
            checkboxHeader.CheckedChanged += new EventHandler(CheckBoxHeader_OnCheckedChanged);
            dgvCounties.Controls.Add(checkboxHeader);
        }
Пример #2
0
        /// <summary>
        /// Use this function if you do not add your columns at design time.
        /// </summary>
        /// <param name="colType"></param>
        /// <returns></returns>
        private DataGridViewColumn SetupColumn(VaultGridColumn colType)
        {
            DataGridViewColumn column = null;

            switch (colType)
            {
            case VaultGridColumn.ColumnIndex:
                column            = new KryptonDataGridViewTextBoxColumn();
                column.HeaderText = "Index";
                column.Name       = "ColumnIndex";
                column.SortMode   = DataGridViewColumnSortMode.Programmatic;
                column.Width      = 79;
                return(column);

            case VaultGridColumn.ColumnHasUCE:
                column            = new KryptonDataGridViewCheckBoxColumn();
                column.HeaderText = "Has UCE?";
                column.Name       = "ColumnHasUCE";
                column.Resizable  = DataGridViewTriState.True;
                column.SortMode   = DataGridViewColumnSortMode.Programmatic;
                column.Width      = 78;
                return(column);

            case VaultGridColumn.ColumnTitle:
                column            = new KryptonDataGridViewTextBoxColumn();// KryptonDataGridViewTextBoxColumn();
                column.HeaderText = "Title";
                column.Name       = "ColumnTitle";
                column.SortMode   = DataGridViewColumnSortMode.Programmatic;
                column.Width      = 79;
                return(column);

            case VaultGridColumn.ColumnGenre:
                column            = new KryptonDataGridViewTreeTextColumn();
                column.HeaderText = "Genre";
                column.Name       = "ColumnGenre";
                column.SortMode   = DataGridViewColumnSortMode.Programmatic;
                column.Width      = 79;
                return(column);

            case VaultGridColumn.ColumnCoverArtFile:
                column            = new KryptonDataGridViewTextBoxColumn();
                column.HeaderText = "Cover Art";
                column.Name       = "ColumnCoverArtFile";
                column.SortMode   = DataGridViewColumnSortMode.Programmatic;
                column.Width      = 79;
                return(column);

            case VaultGridColumn.ColumnBezelArtFile:
                column            = new KryptonDataGridViewTextBoxColumn();
                column.HeaderText = "Bezel Art";
                column.Name       = "ColumnBezelArtFile";
                column.SortMode   = DataGridViewColumnSortMode.Programmatic;
                column.Width      = 79;
                return(column);

            case VaultGridColumn.ColumnUseInternalCore:
                column            = new KryptonDataGridViewCheckBoxColumn();
                column.HeaderText = "Use Internal Core";
                column.Name       = "ColumnUseInternalCore";
                //((KryptonDataGridViewCheckBoxColumn)column).
                column.Resizable = DataGridViewTriState.True;
                column.SortMode  = DataGridViewColumnSortMode.Programmatic;
                column.Width     = 78;
                return(column);

            case VaultGridColumn.ColumnEmulatorCoreFile:
                column            = new KryptonDataGridViewTextBoxColumn();
                column.HeaderText = "Emulator Core";
                column.Name       = "ColumnEmulatorCoreFile";
                column.SortMode   = DataGridViewColumnSortMode.Programmatic;
                column.Width      = 79;
                return(column);

            case VaultGridColumn.ColumnOverLayFile:
                column            = new KryptonDataGridViewTextBoxColumn();
                column.HeaderText = "Overlay?";
                column.Name       = "ColumnOverLayFile";
                column.SortMode   = DataGridViewColumnSortMode.Programmatic;
                column.Width      = 79;
                return(column);

            case VaultGridColumn.ColumnROMFile:
                column            = new KryptonDataGridViewTextBoxColumn();
                column.HeaderText = "ROM";
                column.Name       = "ColumnROMFile";
                column.SortMode   = DataGridViewColumnSortMode.Programmatic;
                column.Width      = 79;
                return(column);

            case VaultGridColumn.ColumnDescription:
                column            = new KryptonDataGridViewTextBoxColumn();
                column.HeaderText = "Description";
                column.Name       = "ColumnDescription";
                column.SortMode   = DataGridViewColumnSortMode.Programmatic;
                column.Width      = 79;
                return(column);

            case VaultGridColumn.ColumnResizeImages:
                column            = new KryptonDataGridViewCheckBoxColumn();
                column.HeaderText = "Resize Images?";
                column.Name       = "ColumnResizeImages";
                column.Resizable  = DataGridViewTriState.True;
                column.SortMode   = DataGridViewColumnSortMode.Programmatic;
                column.Width      = 78;
                return(column);

            default:
                throw new Exception("Unknown Column Type !! TODO improve that !");
            }
        }