Copy Current Record


Author
Message
Edhy Rijo
E
StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Juan Carlos Pazos (02/15/2009)
Hi Edhy

Thanks for your commentes. Can you post a sample of how to make the EditChildRecord?

Regards

Juan Carlos, here ae the two mehods need for this functionality, I simply copied them from the source to the form where the ListView is being used and modified as needed.

''' <summary>

''' 09/08/2008 Edhy Rijo

''' Edits the currently selected child record

''' This method should be use temporarily until the internal one in the listview

''' is made available by SF Team

''' </summary>

''' <remarks></remarks>

Private Sub EditChildRecord()

     Dim bo As BusinessLayer = Me.lstItems.BusinessObject

     '-- If no business object is attached then there is nothing to do

     If bo Is Nothing Then Exit Sub

'-- See if a snapshot should be taken

If Me.lstItems.AutoSnapshotBusinessObject Then bo.SaveCurrentDataTableToSnapshot(Me.lstItems.AutoSnapshotKey)

'-- Ensure the the correct record is selected in case it had been moved by the developer

               bo.NavigateToPrimaryKey(Me.lstItems.SelectedItems(0).Tag)

               '-- Place the record in edit mode

               bo.Edit()

               '-- See if there is a child dialog

               If lstItems.ChildForm IsNot Nothing Then

                    '-- Raise the before child form executed event

                    ' OnBeforeChildFormExecuted(New ListViewBeforeChildExecuteEventArgs(ListViewChildFormAction.Edit))

                    '-- Call the child form and create the args

                    Dim args As New MicroFour.StrataFrame.UI.Windows.Forms.ListViewChildFormResultsEventArgs(MicroFour.StrataFrame.UI.ListViewChildFormAction.Edit, Me.lstItems.ChildForm.ShowDialog())

                    ''-- Raise the event

                    Me.lstItems_ChildFormResults(Me.lstItems, args)

                    '-- See if the list should be requeried

                    If args.Requery Then

                         '-- Save off the primary key value

                         Dim reselect As Boolean = True

                         Dim pk As Object = Nothing

                         Try

                              pk = bo.CurrentRow(bo.PrimaryKeyField)

                         Catch ex As Exception

                              reselect = False

                         End Try

                         '-- Requery the list

                         Me.lstItems.Requery()

                         '-- Attempt to select the item

                         If reselect Then SelectIndexByPrimaryKey(pk)

                    End If

               End If

End Sub

''' <summary>

''' 09/08/2008 Edhy Rijo

''' Attempts to select the row index associated with the specified primary key

''' This method is used by EditChildRecord

''' This method should be use temporarily until the internal one in the listview

''' is made available by SF Team

''' </summary>

''' <param name="primaryKey"></param>

''' <remarks></remarks>

Private Sub SelectIndexByPrimaryKey(ByVal primaryKey As Object)

     For Each i As ListViewItem In Me.lstItems.Items

          If i.Tag.Equals(primaryKey) Then

               '-- Select the item

               i.Selected = True

               '-- Ensure this item is visible

               Me.lstItems.EnsureVisible(Me.lstItems.Items.IndexOf(i))

               '-- Nothing left to do

               Exit For

          End If

     Next

End Sub



Edhy Rijo

Juan Carlos Pazos
Juan Carlos Pazos
StrataFrame User (228 reputation)StrataFrame User (228 reputation)StrataFrame User (228 reputation)StrataFrame User (228 reputation)StrataFrame User (228 reputation)StrataFrame User (228 reputation)StrataFrame User (228 reputation)StrataFrame User (228 reputation)StrataFrame User (228 reputation)
Group: Forum Members
Posts: 144, Visits: 227
Hi Edji

The routine works great thanks. Just a simple question:

How do I exclude some fields from being copied? I did in a Maintenance form and works:

If col.ColumnName = Me.PublicacionesBO1.PrimaryKeyField Then

Continue For

End If

If col.ColumnName = Me.PublicacionesBO1.Ofertas Then

 Continue For

End If

... some other fields here

Me.PublicacionesBO1.CurrentRow(col) = copyRow(col)

But using the same logic in the ListView, the record is not copied.

Do you have some ideas?

Regards

Smile Everything is possible, just keep trying...

Edhy Rijo
E
StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Hi Juan Carlos,

Sorry, but I have no idea how to accomplish what you want. Maybe Trent or somebody else can jump in here.

Edhy Rijo

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search