Esempio n. 1
0
        private void dataGridView_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            // form call to edit cell value
            if ((clrColExists || srcColExists) && e.Button == MouseButtons.Left)
            {
                int colInd = e.ColumnIndex;
                int rowInd = e.RowIndex;

                if (0 <= colInd && colInd < dataGridView.Columns.Count && rowInd >= 0)
                {
                    var    cell    = dataGridView[colInd, rowInd];
                    string colName = dataGridView.Columns[colInd].DataPropertyName;

                    if (colName == "Color")
                    {
                        // color selection form call
                        dataGridView.EndEdit();
                        var frmSelectColor = new FrmSelectColor {
                            SelectedColor =
                                cell.Value == null ? Color.Empty : StrToColor(cell.Value.ToString())
                        };

                        if (frmSelectColor.ShowDialog() == DialogResult.OK)
                        {
                            cell.Value = frmSelectColor.SelectedColorName;
                            dataGridView.EndEdit();
                        }
                    }
                    else if (colName == "Source")
                    {
                        // call the source code edit form
                        dataGridView.EndEdit();
                        var frmEditSource = new FrmEditSource()
                        {
                            MaxLength = Table.Columns[colName].MaxLength,
                            Source    = cell.Value.ToString()
                        };

                        if (frmEditSource.ShowDialog() == DialogResult.OK)
                        {
                            cell.Value = frmEditSource.Source;
                            dataGridView.EndEdit();
                        }
                    }
                }
            }
        }
Esempio n. 2
0
        private void dataGridView_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            // вызов формы для редактирования значения ячейки
            if ((clrColExists || srcColExists) && e.Button == MouseButtons.Left)
            {
                int colInd = e.ColumnIndex;
                int rowInd = e.RowIndex;

                if (0 <= colInd && colInd < dataGridView.Columns.Count && rowInd >= 0)
                {
                    DataGridViewCell cell    = dataGridView[colInd, rowInd];
                    string           colName = dataGridView.Columns[colInd].DataPropertyName;

                    if (colName == "Color")
                    {
                        // вызов формы выбора цвета
                        dataGridView.EndEdit();
                        FrmSelectColor frmSelectColor = new FrmSelectColor();
                        frmSelectColor.SelectedColor = cell.Value == null ?
                                                       Color.Empty : StrToColor(cell.Value.ToString());

                        if (frmSelectColor.ShowDialog() == DialogResult.OK)
                        {
                            cell.Value = frmSelectColor.SelectedColorName;
                            dataGridView.EndEdit();
                        }
                    }
                    else if (colName == "Source")
                    {
                        // вызов формы редактирования исходного кода
                        dataGridView.EndEdit();
                        FrmEditSource frmEditSource = new FrmEditSource()
                        {
                            MaxLength = Table.Columns[colName].MaxLength,
                            Source    = cell.Value.ToString()
                        };

                        if (frmEditSource.ShowDialog() == DialogResult.OK)
                        {
                            cell.Value = frmEditSource.Source;
                            dataGridView.EndEdit();
                        }
                    }
                }
            }
        }
Esempio n. 3
0
        private void dataGridView_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            // вызов формы для редактирования значения ячейки
            if ((clrColExists || srcColExists) && e.Button == MouseButtons.Left)
            {
                int colInd = e.ColumnIndex;
                int rowInd = e.RowIndex;

                if (0 <= colInd && colInd < dataGridView.Columns.Count && rowInd >= 0)
                {
                    DataGridViewCell cell = dataGridView[colInd, rowInd];
                    string colName = dataGridView.Columns[colInd].DataPropertyName;

                    if (colName == "Color")
                    {
                        // вызов формы выбора цвета
                        dataGridView.EndEdit();
                        FrmSelectColor frmSelectColor = new FrmSelectColor();
                        frmSelectColor.SelectedColor = cell.Value == null ? 
                            Color.Empty : StrToColor(cell.Value.ToString());

                        if (frmSelectColor.ShowDialog() == DialogResult.OK)
                        {
                            cell.Value = frmSelectColor.SelectedColorName;
                            dataGridView.EndEdit();
                        }
                    }
                    else if (colName == "Source")
                    {
                        // вызов формы редактирования исходного кода
                        dataGridView.EndEdit();
                        FrmEditSource frmEditSource = new FrmEditSource();
                        frmEditSource.Source = cell.Value.ToString();

                        if (frmEditSource.ShowDialog() == DialogResult.OK)
                        {
                            cell.Value = frmEditSource.Source;
                            dataGridView.EndEdit();
                        }
                    }
                }
            }
        }