コード例 #1
0
        private void indexGrid_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
        {
            if (e.ColumnIndex != 0)
            {
                return;
            }

            System.Diagnostics.Trace.WriteLine("Validate starting");
            DataGridViewComboBoxCell colCell =
                (DataGridViewComboBoxCell)indexGrid.Rows[e.RowIndex].Cells[0];
            DataGridViewComboBoxCell sortCell =
                (DataGridViewComboBoxCell)indexGrid.Rows[e.RowIndex].Cells[1];

            IndexColumnGridRow gr    = indexColumnBindingSource.Current as IndexColumnGridRow;
            string             value = e.FormattedValue as string;

            if (value == "<None>")
            {
                colCell.Value  = null;
                sortCell.Value = null;
                gr.ColumnName  = null;
                gr.SortOrder   = null;
            }
            else
            {
                colCell.Value = e.FormattedValue;

                if (!String.IsNullOrEmpty(colCell.Value as string) &&
                    String.IsNullOrEmpty(sortCell.Value as string))
                {
                    gr.SortOrder = "Ascending";
                }
                sortCell.Value = gr.SortOrder;
            }
        }
コード例 #2
0
        public IndexColumnEditorDialog(List <IndexColumn> ic)
        {
            InitializeComponent();
            table        = ic[0].OwningIndex.Table;
            indexColumns = ic;

            foreach (Column c in table.Columns)
            {
                if (!String.IsNullOrEmpty(c.ColumnName))
                {
                    columnNames.Add(c.ColumnName);
                }
            }

            for (int i = 0; i < indexColumns.Count; i++)
            {
                IndexColumnGridRow row = new IndexColumnGridRow();
                row.ColumnName = indexColumns[i].ColumnName;
                row.SortOrder  = indexColumns[i].SortOrder.ToString();
                gridRows.Add(row);
            }

            columnName.Items.Add("<None>");
            columnName.Items.AddRange((object[])columnNames.ToArray());

            sortOrder.Items.Add("Ascending");
            sortOrder.Items.Add("Descending");

            indexColumnBindingSource.DataSource = gridRows;
        }
コード例 #3
0
        public IndexColumnEditorDialog(List<IndexColumn> ic)
        {
            table = ic[0].OwningIndex.Table;
            indexColumns = ic;
            InitializeComponent();

            foreach (Column c in table.Columns)
            {
                if (!String.IsNullOrEmpty(c.ColumnName))
                    columnNames.Add(c.ColumnName);
            }

            for (int i=0; i < indexColumns.Count; i++)
            {
                IndexColumnGridRow row = new IndexColumnGridRow();
                row.ColumnName = indexColumns[i].ColumnName;
                row.SortOrder = indexColumns[i].SortOrder.ToString();
                gridRows.Add(row);
            }

            columnName.Items.Add("<None>");
            columnName.Items.AddRange((object[])columnNames.ToArray());

            sortOrder.Items.Add("Ascending");
            sortOrder.Items.Add("Descending");

            indexColumnBindingSource.DataSource = gridRows;
        }