B
Bob Ranck
This is a follow response to questions raised by
Kathleen Dollard.
The Original problem was Binding Manager refuses to
position on the proper row after an ADDNEW.
This is the BindingManager wont go to Row 9 Problem.
If you look for the comments on the Debug lines you can
see that the progress in count and position. We are
adding a 10th Row to this dataview.
Here is the NewCustomerRow Functions from my
DataAccessLayer
Friend Sub AddNewCustomer()
Dim newCustomer As LProDataSet.CustomerRow
newCustomer = CType(AddRowThroughBinding().Row,
LProDataSet.CustomerRow)
newCustomer.BeginEdit()
newCustomer.CompanyName = ""
newCustomer.Address1 = ""
newCustomer.City = ""
newCustomer.ST = ""
newCustomer.Zip = ""
newCustomer.ContactLastName = ""
newCustomer.Phone1 = ""
newCustomer.EndEdit()
End Sub
Private Function AddRowThroughBinding() As DataRowView
Try
Debug.WriteLine(m_DalBindingManager.Count)
'If this view was filtered this might be 3 Rows
Debug.WriteLine(m_DalBindingManager.Position)
'and this might be 2
'Kill any edits
DaLBindingManager.EndCurrentEdit()
'Kill any Filters
Me.FilterThroughBinding("")
Debug.WriteLine(m_DalBindingManager.Count)
'Now I have a count of all Nine Rows
Debug.WriteLine(m_DalBindingManager.Position)
'and its pointing to 0
'Add the New Row
DaLBindingManager.AddNew()
Debug.WriteLine(m_DalBindingManager.Count)
'Success I have 10 Rows
Debug.WriteLine(m_DalBindingManager.Position)
'But darn its pointing to 0 instead of 9
'Kill the Edit before Returning the RowView
DaLBindingManager.EndCurrentEdit()
Debug.WriteLine(m_DalBindingManager.Count)
m_DalBindingManager.Position =
m_DalBindingManager.Count - 1 'No help - still points to 0
Debug.WriteLine(m_DalBindingManager.Position)
Return CType(DaLBindingManager.Current,
DataRowView)
Catch ex As System.Exception
MessageBox.Show("Error: " & ex.Message, "Add
New Error", MessageBoxButtons.OK, MessageBoxIcon.Error,
MessageBoxDefaultButton.Button1)
End Try
End Function
Thank You
Kathleen Dollard.
The Original problem was Binding Manager refuses to
position on the proper row after an ADDNEW.
This is the BindingManager wont go to Row 9 Problem.
If you look for the comments on the Debug lines you can
see that the progress in count and position. We are
adding a 10th Row to this dataview.
Here is the NewCustomerRow Functions from my
DataAccessLayer
Friend Sub AddNewCustomer()
Dim newCustomer As LProDataSet.CustomerRow
newCustomer = CType(AddRowThroughBinding().Row,
LProDataSet.CustomerRow)
newCustomer.BeginEdit()
newCustomer.CompanyName = ""
newCustomer.Address1 = ""
newCustomer.City = ""
newCustomer.ST = ""
newCustomer.Zip = ""
newCustomer.ContactLastName = ""
newCustomer.Phone1 = ""
newCustomer.EndEdit()
End Sub
Private Function AddRowThroughBinding() As DataRowView
Try
Debug.WriteLine(m_DalBindingManager.Count)
'If this view was filtered this might be 3 Rows
Debug.WriteLine(m_DalBindingManager.Position)
'and this might be 2
'Kill any edits
DaLBindingManager.EndCurrentEdit()
'Kill any Filters
Me.FilterThroughBinding("")
Debug.WriteLine(m_DalBindingManager.Count)
'Now I have a count of all Nine Rows
Debug.WriteLine(m_DalBindingManager.Position)
'and its pointing to 0
'Add the New Row
DaLBindingManager.AddNew()
Debug.WriteLine(m_DalBindingManager.Count)
'Success I have 10 Rows
Debug.WriteLine(m_DalBindingManager.Position)
'But darn its pointing to 0 instead of 9
'Kill the Edit before Returning the RowView
DaLBindingManager.EndCurrentEdit()
Debug.WriteLine(m_DalBindingManager.Count)
m_DalBindingManager.Position =
m_DalBindingManager.Count - 1 'No help - still points to 0
Debug.WriteLine(m_DalBindingManager.Position)
Return CType(DaLBindingManager.Current,
DataRowView)
Catch ex As System.Exception
MessageBox.Show("Error: " & ex.Message, "Add
New Error", MessageBoxButtons.OK, MessageBoxIcon.Error,
MessageBoxDefaultButton.Button1)
End Try
End Function
Thank You