Example #1
0
        /// <summary>
        /// Activate editor for cell
        /// </summary>
        /// <param name="r"></param>
        /// <param name="c"></param>

        private void EditCellValue(
            int r,
            int c)
        {
            BandedGridView bgv = RulesGrid.MainView as BandedGridView;

            bgv.ClearSelection();
            bgv.SelectCell(r, bgv.Columns[c]);
            bgv.FocusedRowHandle = r;
            bgv.FocusedColumn    = bgv.Columns[c];
            bgv.ShowEditor();             // doesn't seem to open dropdown
            //Application.DoEvents();

            //ColorDialog cd = new ColorDialog();
            //cd.Color = RulesGrid.GetCellBackColor(r, BackColorCol);
            //DialogResult dr = cd.ShowDialog(this);
            //if (dr != DialogResult.OK) return;

            //CellInfo ci = RulesGrid.GetCellInfo(r, c);
            //RulesGrid.DataTable.Rows[ci.DataRowIndex][ci.DataColIndex] = cd.Color;
            //bgv.RefreshRowCell(r, ci.GridColumn);

            //RulesGrid.AddNewRowAsNeeded();
            return;
        }
Example #2
0
        private void BandedGridView_CellValueChanging(object sender, CellValueChangedEventArgs e)
        {
            if (InSetup)
            {
                return;
            }

            int ri = e.RowHandle;
            int ci = e.Column.AbsoluteIndex;

            if (e.Column == BackColor1 || e.Column == IconImage)             // force completion of edit
            {
                object value = e.Value;
                BandedGridView.CloseEditor();                  // Closes editor
                this.BeginInvoke((Action)(() =>                // safe way to execute lines below
                {
                    BandedGridView.SetRowCellValue(e.RowHandle, e.Column, value);
                    BandedGridView.ShowEditor();                     // open editor again
                }));
                return;
            }

            else if (ci == ValCol || ci == ValCol2)
            {
                if (e.Value == null || Lex.Ne(e.Value.ToString(), "User-defined"))
                {
                    return;                                                                                // blank out if user-defined
                }
                //ComboBoxEdit cb = BandedGridView.ActiveEditor as ComboBoxEdit;

                BandedGridView.CloseEditor();                                  // Closes editor

                this.BeginInvoke((Action)(() =>                                // safe way to execute lines below
                {
                    BandedGridView.SetRowCellValue(e.RowHandle, e.Column, ""); // blank value
                    BandedGridView.ShowEditor();                               // open editor again
                }));
            }

            return;
        }