C# DataGridView.IsCurrentRowDirty()未使用可编辑的DataGridViewComboxColumn设置

C# DataGridView.IsCurrentRowDirty()未使用可编辑的DataGridViewComboxColumn设置,c#,winforms,datagridview,C#,Winforms,Datagridview,我有一个DataGridView和一个datagridviewcomboxcolumn绑定到一个列表。在这个组合框列中,我允许用户选择现有值或键入新值。当用户选择现有值时,IsCurrentRowDirty()正确返回true。当用户键入值时,IsCurrentRowDirty()总是返回false,而它显然应该返回true 我已尝试在CurrentCellDirtyStateChanged事件中调用DataGridView.CommittedIt(),但不起作用 如何在DataGridView

我有一个
DataGridView
和一个
datagridviewcomboxcolumn
绑定到一个
列表
。在这个组合框列中,我允许用户选择现有值或键入新值。当用户选择现有值时,
IsCurrentRowDirty()
正确返回true。当用户键入值时,
IsCurrentRowDirty()
总是返回false,而它显然应该返回true

我已尝试在
CurrentCellDirtyStateChanged
事件中调用
DataGridView.CommittedIt()
,但不起作用

如何在
DataGridViewComboBoxColumn
中获取用户输入的值,以将行设置为脏行

相关代码如下

谢谢

凯尔

公共品牌()
{
DataGridViewComboBoxColumn组合框=(DataGridViewComboxColumn)dgvReference.Columns[(int)ReferenceColumnsIndex.Brand];
comboBox.DisplayMember=“Name”;
comboBox.ValueMember=“Self”/“Self”返回“this”
comboBox.DataSource=品牌;
}
//这使得用户可以编辑DataGridViewComboBoxColumn
private void dgvReference_EditingControlShowing(对象发送方,DataGridViewEditingControlShowingEventArgs e)
{
DataGridViewComboxColumn=GetColumn(DGVRReference,
(int)参考列索引品牌);
if(列!=null)
{
ComboBox ComboBox=e.控件作为ComboBox;
如果(组合框!=null)
{
comboBox.DropDownStyle=ComboBoxStyle.DropDown;
}
}
}
private void dgvReference_CellValidating(对象发送方,DataGridViewCellValidatingEventArgs e)
{
开关(如列索引)
{
案例(int)参考列sindex.Brand:
DataGridViewComboBoxColumn comboBox=dgvReference.Columns[(int)ReferenceColumnsIndex.Brand]作为DataGridViewComboxColumn;
if(e.ColumnIndex==comboBox.DisplayIndex)
{
IBrand brand=新品牌(如FormattedValue.ToString());
如果(!brands.Contains(brand))
{
//如果品牌不存在,则将其添加到组合框的数据源中
品牌。添加(品牌);

dgvReference.NotifyCurrentCellDirty(true);//好的,我想出了如何强制
IsCurrentRowDirty()
方法返回
true
。我需要添加以下代码行,如示例所示:

dgvReference.NotifyCurrentCellDirty(true);
对新输入的品牌调用此函数将强制
IsCurrentRowDirty()
方法的行返回true

dgvReference.NotifyCurrentCellDirty(true);