我一直遇到一个错误,提示
以下是我的代码部分:
DataGridViewComboBox值无效
。似乎它也处于无限循环中:我会点击 ok,它会不断弹出。我正在运行一个使用 C# 和 .NET 编写的窗口表单应用程序。有人知道如何修复此错误吗?以下是我的代码部分:
// authorityTypeDataGridViewTextBoxColumn
//
this.authorityTypeDataGridViewTextBoxColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
this.authorityTypeDataGridViewTextBoxColumn.DataPropertyName = "AuthorityType";
this.authorityTypeDataGridViewTextBoxColumn.DataSource = this.AuthorityTypeBindingSource;
this.authorityTypeDataGridViewTextBoxColumn.DisplayMember = "Description";
this.authorityTypeDataGridViewTextBoxColumn.DisplayStyle = System.Windows.Forms.DataGridViewComboBoxDisplayStyle.ComboBox;
this.authorityTypeDataGridViewTextBoxColumn.Frozen = true;
this.authorityTypeDataGridViewTextBoxColumn.HeaderText = "AuthorityType";
this.authorityTypeDataGridViewTextBoxColumn.MaxDropDownItems = 100;
this.authorityTypeDataGridViewTextBoxColumn.Name = "authorityTypeDataGridViewTextBoxColumn";
this.authorityTypeDataGridViewTextBoxColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
this.authorityTypeDataGridViewTextBoxColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
this.authorityTypeDataGridViewTextBoxColumn.ValueMember = "Value";
this.authorityTypeDataGridViewTextBoxColumn.Width = 121;
//
// AuthorityTypeBindingSource
//
this.AuthorityTypeBindingSource.DataMember = "AuthorityType";
this.AuthorityTypeBindingSource.DataSource = this.lookUpDataSet;
请问有什么建议吗?
以下是处理程序:
private void TaskSummaryGrid_DataError(object sender, DataGridViewDataErrorEventArgs e)
{
MessageBox.Show(this, e.Exception.Message);
e.Cancel = true;
}
InitializeComponent
下面,另一个在声明处。确保这两个引用都更改为DataGridViewComboBoxColumn
。一旦正确运行,请考虑更改名称。 - LarsTech