Esempio n. 1
0
        // 初始化DataGridView
        private void iniDataGridViewDW()
        {
            DataGridViewColumn column = new DataGridViewDataComboColumn();

            column.Name = "title_id";
            (column as DataGridViewDataComboColumn).SDisplayField  = "title_id,title,type,price,ytd_sales,notes,pubdate";
            (column as DataGridViewDataComboColumn).SDisplayMember = "title_id";
            (column as DataGridViewDataComboColumn).SKeyWords      = "title_id";

            (column as DataGridViewDataComboColumn).DataSource = createTable();
            dataGridView1.Columns.Add(column);
        }
        public override void InitializeEditingControl(int rowIndex, object
                                                      initialFormattedValue, DataGridViewCellStyle dataGridViewCellStyle)
        {
            base.InitializeEditingControl(rowIndex, initialFormattedValue,
                                          dataGridViewCellStyle);
            DataGridViewDataComboEditingControl datacomboControl =
                DataGridView.EditingControl as DataGridViewDataComboEditingControl;

            datacomboControl.PopupGridAutoSize = true;
            DataGridViewDataComboColumn datacomboColumn =
                (DataGridViewDataComboColumn)OwningColumn;

            datacomboControl.sDisplayMember = datacomboColumn.SDisplayMember;//以下3句必须放在datasource设置前面
            datacomboControl.sDisplayField  = datacomboColumn.SDisplayField;
            datacomboControl.sKeyWords      = datacomboColumn.SKeyWords;
            datacomboControl.Text           = (string)this.Value;

            datacomboControl.DataSource = datacomboColumn.DataSource;



            datacomboControl.RowFilterVisible = true;  //此句必须放在datasource设置后面
        }
        // 初始化DataGridView
        private void iniDataGridViewDW()
        {
            DataGridViewColumn column = new DataGridViewDataComboColumn();
            column.Name = "title_id";
            (column as DataGridViewDataComboColumn).SDisplayField = "title_id,title,type,price,ytd_sales,notes,pubdate";
            (column as DataGridViewDataComboColumn).SDisplayMember = "title_id";
            (column as DataGridViewDataComboColumn).SKeyWords = "title_id";

            (column as DataGridViewDataComboColumn).DataSource = createTable();
            dataGridView1.Columns.Add(column);
        }