var fs = require('fs');
var arr = [ [ 'text1' ],[ 'text2', 'text34','text444'],[ 'text3243', 'abc' ]]
var file = fs.createWriteStream('newFile.txt');
file.on('error', function(err) { /* Use error handler */ });
arr.forEach(function(item) { file.write(item.join(',') + '\n'); });
file.end();
如果我执行此操作会出现此错误:
Cell enter - Operation is not valid because it results in a reentrant call to the SetCurrentCellAddressCore function
我只想阻止用户在Private Sub dg1_CellEnter(sender As Object, e As DataGridViewCellEventArgs) Handles dg1.CellEnter
if e.columnindex = 4
if dg1.CurrentRow.Cells("id").Value = 0
dg1.endEdit(true)
msgbox("choose any item in cell3 before you can proceed here")
dg1.CurrentCell = dg1.CurrentRow.Cells(3)
exit sub
end
'my code here . . .
end if
End Sub
中输入或执行我的代码
没有选择cell 4
当用户在cell 3
中选择一个项目时,cell 3
的值将取决于cells("id")
值的ID。但是当我点击cell 3
时会出现错误。
答案 0 :(得分:2)
您获得可重入异常的原因是设置当前单元格将强制触发CellEnter事件。要避免此异常,请将其添加到您的代码中:
Delegate Sub SetColumnIndex(ByVal i As Integer)
Private Sub Mymethod(ByVal columnIndex As Integer)
dg1.CurrentCell = dg1.CurrentRow.Cells(columnIndex)
End Sub
然后在你的代码中:
if dg1.CurrentRow.Cells("id").Value = 0
msgbox("choose any item in cell3 before you can proceed here")
Dim method As New SetColumnIndex(AddressOf Mymethod)
dg1.BeginInvoke(method, 3)
Exit Sub
end if
如果这不起作用,请通知我。