爲了在此DatagridViewComboBox中顯示ReadAccess
枚舉成員,還需要做些什麼?如何在DataGridViewComboBox中顯示枚舉類型成員?
ReadDataGridViewComboBoxColumn.Items.Clear();
ReadDataGridViewComboBoxColumn.Items.AddRange(ReadAccess.None, ReadAccess.Allowed);
ReadDataGridViewComboBoxColumn.ValueType = typeof(ReadAccess);
這裏是關於DataGridView的設計器生成的代碼:
this.rolesDataGridView.AutoGenerateColumns = false;
this.rolesDataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.TableNameDataGridViewTextBoxColumn,
this.ReadDataGridViewComboBoxColumn,
this.WriteDataGridViewComboBoxColumn,
this.ReadCodeDataGridViewComboBoxColumn,
this.ProcessDataGridViewCheckBoxColumn,
this.AdministrateDataGridViewCheckBoxColumn});
this.rolesDataGridView.DataSource = this.bsTablePermissions;
終於,在InitializeComponent();
後,我設置的DataGridView的DataSource:
this.rolesDataGridView.DataSource = this.RoleTablePermissions; // a bindingsource list
你完成了'this.Controls.Add(ReadDataGridViewComboBoxColumn)'或類似嗎? – 2010-11-08 02:41:01
@George:是的,當然...但是當我運行該項目時,組合框被凍結,我無法打開它的列表... – 2010-11-08 02:44:49
是否有更多的代碼來實例化DataGridView比這隻? – 2010-11-08 02:50:48