简体   繁体   English

如果datagridview处于editmode,则不会触发Button.Click事件

[英]Button.Click event doesn't fire if datagridview is in editmode

I have a datagridView (unbound for several reasons). 我有一个datagridView(由于一些原因未绑定)。 When the user changes something I am saving the new value in a tempTable 当用户更改某些内容时,我会将新值保存在tempTable中

 Private Sub fgFields_AfterEdit(sender As Object, e As C1.Win.C1FlexGrid.RowColEventArgs) Handles fgFields.AfterEdit
    Cursor.Current = Cursors.WaitCursor
    SaveField(e.Row)
    Cursor.Current = Cursors.Default
End Sub

I have also a button (btnSave) that saves the values from datagrid , among with other values to a database: 我还有一个按钮(btnSave),它将datagrid中的值以及其他值保存到数据库中:

Private Sub btnSave_Click(sender As System.Object, e As System.EventArgs) Handles btnSave.Click
    SaveFileDef("SAVE")
End Sub

My problem is that if I start editing the cell I need to click somewhere else to fire the after_edit. 我的问题是,如果我开始编辑单元格,则需要单击其他位置以触发after_edit。 If the user click on btnSave the event After_Edit is fired but not the button.Click!!!! 如果用户单击btnSave,则事件After_Edit被触发,但按钮未被触发。

So the code in the event btnSave.Click is not running. 因此,事件btnSave.Click中的代码未运行。

Any ideas how to overcome this strange behaviour? 任何想法如何克服这种奇怪的行为?

So .. you use ComponentOne Flexgrid .. 所以..您使用ComponentOne Flexgrid ..

try this way on Event RowValidating 事件RowValidating上尝试这种方式

 e.Cancel = True

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM