UltraWinGrid enter edit mode issue

2019-08-04 13:22发布

I have an UltraWinGrid and I want to give the focus to a specific cell and make it enter edit mode programmatically (no click). So I did this :

If myUltraWinGrid.ActiveRow IsNot Nothing Then
myUltraWinGrid.ActiveCell = myUltraWinGrid.ActiveRow.Cells("foo")
myUltraWinGrid.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.EnterEditMode)
Else
myUltraWinGrid.ActiveCell = myUltraWinGrid.Rows(0).Cells("foo")
myUltraWinGrid.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.EnterEditMode)
EndIf

Which should work but it only gives focus to the row (no edit mode).

fooColumn   
   |
  \_/

enter image description here

2条回答
手持菜刀,她持情操
2楼-- · 2019-08-04 14:03

I don't know why but calling it with BeginInvoke solved the issue.

BeginInvoke(New MethodInvoker(AdressOf SetFocusToRow))

Private sub SetFocusToRow()
{
  myUltraWinGrid.ActiveCell = myUltraWinGrid.ActiveRow.Cells("foo")
  myUltraWinGrid.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.EnterEditMode)
}
查看更多
戒情不戒烟
3楼-- · 2019-08-04 14:20

Because it's executed by another thread by some reason

myUltraWinGrid.BeginInvoke(new MethodInvoker(()=> myUltraWinGrid.PerformAction(UltraGridAction.EnterEditMode)));

查看更多
登录 后发表回答