Edhy Rijo
|
|
Group: StrataFrame Users
Posts: 2.4K,
Visits: 23K
|
Hi Trent, First, thanks for all the enhancements done to the ListView, very impressive I setup a form to test the ListView and found the following issues: - Moving the record pointer in the ToolStrip button does not update/refresh the ListView.
- Creating a new record or modifying an existing one does not Refresh the ListView with the updated data.
I tested the functionality of the Add/Delete/Edit Objects and they all worked as expected. One question, when using the ListView with a child BO, I may need to have buttons for Save/Undo if not using a childform object, would you consider adding a SaveObject/UndoObject as well for this case? Please take a loot at the video in this link: http://www.progytech.com/videos/Beta_ListView\Beta_ListView.html
Edhy Rijo
|
|
|
Trent Taylor
|
|
Group: StrataFrame Developers
Posts: 6.6K,
Visits: 6.9K
|
Moving the record pointer in the ToolStrip button does not update/refresh the ListView. Not supposed to. The two are separate. I might add something so that it auto-navigates from an external source, but for now there is not an issue because it wasn't supposed to move. The auto-navigation occurs when the item is selected within the list, not the other way around. Creating a new record or modifying an existing one does not Refresh the ListView with the updated data. You have to handle the ChildFormResults event and if you want it to requery set the event arg and it will then requery itself: e.Requery = True
|
|
|
Trent Taylor
|
|
Group: StrataFrame Developers
Posts: 6.6K,
Visits: 6.9K
|
One question, when using the ListView with a child BO, I may need to have buttons for Save/Undo if not using a childform object, would you consider adding a SaveObject/UndoObject as well for this case? I will consider it. This is pretty far out of the norm since your child logic should not generally be separate from the rest of the environment and there may be more than one BO that requires saving, etc. So this gets more complicated in that sense.
|
|
|
Edhy Rijo
|
|
Group: StrataFrame Users
Posts: 2.4K,
Visits: 23K
|
Trent, Following the ListView enhancements, in the following code Private Sub AddNewChildRecord() '-- If no business object is attached then there is nothing to do If _BusinessObject Is Nothing Then Exit Sub '-- Add the new record _BusinessObject.Add() '-- See if there is a child dialog If _ChildForm IsNot Nothing Then '-- Call the child form and create the args Dim args As New ListViewChildFormResultsEventArgs(_ChildForm.ShowDialog()) '-- Raise the event Me.OnChildFormResults(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 = _BusinessObject.CurrentRow(_BusinessObject.PrimaryKeyField) Catch ex As Exception reselect = False End Try '-- Requery the list Me.Requery() '-- Attempt to select the item If reselect Then SelectIndexByPrimaryKey(pk) End If End IfEnd Sub The code that check if the list should be requeried will only run if a ChildForm exist and that may not be case if no ChildForm is used, but there is still the need for the list to be requeried. Do you think that the new ListView event ChildFormResults could be raised even if a ChildForm is not being used? or is there a way I can manually raise this event so I can force the code to Requery the view to be run at will?
Edhy Rijo
|
|
|
Edhy Rijo
|
|
Group: StrataFrame Users
Posts: 2.4K,
Visits: 23K
|
HI Trent, Still working with the ListView enhancements, I am having a problem when trying to Edit a record in the ListView this time using a ChildForm I get this error: BusinessLayerException There are no rows in the current data table. An edit is not allowed. Source : MicroFour StrataFrame Business Stack Trace: at MicroFour.StrataFrame.Business.BusinessLayer.Edit(Boolean CheckSecurity) at MicroFour.StrataFrame.Business.BusinessLayer.Edit() at MicroFour.StrataFrame.UI.Windows.Forms.ListView.EditChildRecord() at MicroFour.StrataFrame.UI.Windows.Forms.ListView.HandleObjectClick(Object sender, EventArgs e) at System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e) at System.Windows.Forms.ToolStripButton.OnClick(EventArgs e) at System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e) at System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e) at System.Windows.Forms.ToolStripItem.FireEventInteractive(EventArgs e, ToolStripItemEventType met) at System.Windows.Forms.ToolStripItem.FireEvent(EventArgs e, ToolStripItemEventType met) at System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea) at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.ScrollableControl.WndProc(Message& m) at System.Windows.Forms.ToolStrip.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativewindow.OnMessage(Message& m) at System.Windows.Forms.Control.ControlNativewindow.WndProc(Message& m) at System.Windows.Forms.Nativewindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
I don't have any problem when adding new records, and even after adding new records I am able to Edit current records in the listview. For the ChildForm, I created this form with a SF MaintenanceForm class and added the child BO as usual. Please see the attached images.
Edhy Rijo
|
|
|
Trent Taylor
|
|
Group: StrataFrame Developers
Posts: 6.6K,
Visits: 6.9K
|
You probably have a filter applied or something along those lines. Or, you are one or two forms deep and the business object on the ListView is not translated. In the case of the latter, manually set the BusinessObject property on the ListView in code after the BOs have been translated. Thes best place to do this is in the OnLoad method. The latter will only happen if you are already in a ChildForm that has been translated and are calling another child form (grand child). ''' <summary> ''' Provide additional load logic ''' </summary> ''' <param name="e"></param> ''' <remarks></remarks> Protected Overrides Sub OnLoad(ByVal e As System.EventArgs) MyBase.OnLoad(e) '-- Force the ListView to update its reference MyListView.BusinessObject = Me.MyBusinessObject End Sub
|
|
|
Edhy Rijo
|
|
Group: StrataFrame Users
Posts: 2.4K,
Visits: 23K
|
Trent, The problem was that I was not filling the Child BO and was fooled by the data in the Child ListView. In this regard I have a couple of question I need to clarify: - When loading the BO with a fill method, which event is the best one to use:
- Form's Load or
- BO ParentFormLoading
- I am using the following method to fill the child BO
Me .Child_PolicyBO1.FillByParent(Me.InsuredCustomerBO1) - Is this the correct method to use to fill a child BO?
- When filling the ListView I have this code:
Private Sub lvPolicy_ListPopulating(ByVal e As MicroFour.StrataFrame.UI.ListPopulatingEventArgs) Handles lvPolicy.ListPopulating ' Show only child records e.Parameters(0).Value = Me.InsuredCustomerBO1.PK_InsuredCustomerEnd Sub - Is this the correct way since the data in the ListView represent a child BO?
So far everything is working find and I just LOVE the enhancements done to the ListView, but wants to make sure I am using the proper methods and events to keep moving forward with this project. Thanks!
Edhy Rijo
|
|
|
Greg McGuffey
|
|
Group: Forum Members
Posts: 2K,
Visits: 6.6K
|
Based on my SF/.NET experience thus far... When loading the BO with a fill method, which event is the best one to use ParentFormLoading is usually the best. You can use the InitializationPriority to set the order the various BO/lists are loaded. These happen before the form's Load event, so if you need code that depends on loaded lists/BOs, you can then put it in the form Load and you're good to go. I also find that this keeps the code more organized, when dealing with forms with lots of BOs. You then have a small focused method for each BO, rather than a complicated one in the form Load handler. Is this the correct method to use to fill a child BO? Well, correct is a strong word. Correct is very dependent on your situation. However, typically, you can use FillByParent or the FillByParentPrimaryKey method. If you use the FillByParent, you can also set the parent BO instance on the child and skip passing the parent BO, which might be easier. I tend use the FillByParentPrimaryKey, but I'm not going to say this is the way it should be done. I tend to have a database point of view (thus think in terms of PKs), rather than objects. I wouldn't be surprised if this changes as I grow more as .NET programmer. Is this the correct way since the data in the ListView represent a child BO? This depends on what you are doing on the form. If the child data is only represented on the form via the ListView, then this seems fine (and it appears that you are using the FillByParentPrimaryKey, which is fine too). If you have the child BO on the form also, then you might want to use the CopyDataFrom() method instead for the list view. By using this, you will only make one trip to the db (to fill the child BO), then just copy that data into the listview. Hope that gets you thinking some more and helps!
|
|
|
Edhy Rijo
|
|
Group: StrataFrame Users
Posts: 2.4K,
Visits: 23K
|
Greg McGuffey (04/25/2008)
Hope that gets you thinking some more and helps! Thanks Greg, much appreciated.
Edhy Rijo
|
|
|
Edhy Rijo
|
|
Group: StrataFrame Users
Posts: 2.4K,
Visits: 23K
|
Trent, When the ListView shows the ChilForm Dim args As New ListViewChildFormResultsEventArgs(_ChildForm.ShowDialog()) the form is shown as modal as it should, but it is outside the MDI parent form, is there a way to tell the ChildForm to be part of the MDI form?
Edhy Rijo
|
|
|