Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
45
Robust approach to find the added row when calling BindingSource.AddNew()
posted

My form is using a BindingNavigator to drive the UI.  When the "+" "addnew" button is pressed I wan't a new row to show up and have that row be the ActiveRow and be ready for input.  I've coded the following, but am assuming a more robust way exists.  Can someone either confirm my approach or point me in a better direction?

'add a new row using via the bindingsource,

'then find that "added" row to make it the active row and ready for edit/input

me.BindingSource1.AddNew()

Me.UltraGrid1.Focus()
'assuming the added row must have ended up at the end, where else could it be?
Me.UltraGrid1.ActiveRow = Me.UltraGrid1.Rows(Me.UltraGrid1.Rows.Count - 1)
Me.UltraGrid1.PerformAction(UltraGridAction.ActivateCell)
Me.UltraGrid1.PerformAction(UltraGridAction.EnterEditMode)

Thanks