Beta 1.6.5.1: ListView enhanced features....


Author
Message
Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.3K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
Thanks Greg, much appreciated.Smile


Any time!
Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
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?

Technically, yes...however, this defies the nature of a modal dialog.  You actually can do this, but you will have some other issues and side-effects.  You can provide the owner of the dialog when you call the ShowDialog method on a form.  If not provided, then it will appear in the screen.  Initially we started down this path with our medical application and we backed off and let "nature" take its course and we have been far better off.

To allow this to happen through the ListView and ChildDialog form would require that we add another event for you to provide the owner handle.  I will add this to the list and consider it, but it is one of those things that may not make it if there are more liabilities than benefits.

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
Trent L. Taylor (04/27/2008)
[quote]Initially we started down this path with our medical application and we backed off and let "nature" take its course and we have been far better off.

To allow this to happen through the ListView and ChildDialog form would require that we add another event for you to provide the owner handle.  I will add this to the list and consider it, but it is one of those things that may not make it if there are more liabilities than benefits.

Thanks for the confirmation.  I will use it as it is now, so there will be not need to add another event unless you want to open up the possiblities.

Edhy Rijo

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 Trent,

Following my working with the ListView, I noticed that when using the ListView in a One2Many form and there is not record in the parent BO the Add button of the the ListView is still Enabled which will caused an error when clicking this button and the ChildForm will try to update the FK key with no valid record in the parent.

I have been looking at the source and the list events to see where I could put code to disable the cmdAdd button in the list if there is no parent record.  Can you please give me hand here?

Edhy Rijo

Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
Generally I do not allow access to the Toolstrip item if there is not a parent record available.  The ListView will not always be calling a "child" table.  Even though a ChildFormDialog will be shown, it may be the parent record.  This is something that I generally do not fight as I have a single method that I funnel all form enables and disables through...as well as testing on certain security elements.  I generally call this UpdateFormStates()....but you could call it whatever you want.  Then I call this when in the parent BOs Navigated, CurrentTableRefilled, and IsDirtyChanges events.  In this method I then set things that would be handled by a zero count, etc:

Private Sub UpdateFormStates()
    '-- Establish Locals
    Dim isAddAllowed As Boolean = MyParentBO.Count > 0

    '-- Set controls that require a parent record
    MyAddButton.Enabled = isAddAllowed
End Sub

It is possible to add functionality to do this within the ListView, but it would require that a reference to the parent BO be provided and another property or two.  I will consider this when I make some changes before the next update, but for now this is what I would do.  In fact, this is what I do Smile

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
Trent L. Taylor (04/29/2008)
It is possible to add functionality to do this within the ListView, but it would require that a reference to the parent BO be provided and another property or two.  I will consider this when I make some changes before the next update, but for now this is what I would do.  In fact, this is what I do Smile

Hi Trent,

Thanks for the suggestions, I implemented them and still the Add button is always enabled not matter what. 

Following the ListView source code I noticed that in the method UpdateObjectStates() is executed at the end of the PopulateListView() method and this method will set the Add button Enabled=True based on the HasPermission() method which will always return True if no Security is used yet (my case).

I would try adding my code in the AfterRequery() Event, but this event is raised before the UpdateObjectStates() method. 

You can try this and verify that the Add button will always be Enabled.

''' <summary>

''' The main method to populate the list view through the population settings

''' </summary>

''' <remarks></remarks>

Private Sub PopulateListView(ByVal ParamArray Parameters As Object())

     '-- Establish locals

     Dim loBO As BusinessLayer

     Dim lnCnt As Integer

     If Me._PopulationDataSourceSettings IsNot Nothing Then

          '-- Stop the processing of messages

          Me.SuspendLayout()

          Me.BeginUpdate()

          '-- Clear the list

          Items.Clear()

          '-- Get the datatable

          loBO = GetFilledBusinessObject(Parameters)

          '-- Cycle through the rows of the datatable and start populating the list view

          For lnCnt = 0 To loBO.Count - 1

               '-- Move to the row we need

               loBO.MoveAbsolute(lnCnt)

               '-- add the item to the list

               Me.Items.Add(CreateListViewItem(loBO))

          Next

          '-- Resume the drawing and processing

          Me.EndUpdate()

          Me.ResumeLayout()

     End If

     RaiseAfterRequeryEvent()

     '-- Update the states of the objects

     UpdateObjectStates()

End Sub



Edhy Rijo

Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.3K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
Edhy,



You need to call the UpdateObjectStates() method whenever the monitored state changes. I.e. in this case, as Trent mentioned, you need to call this when the state of the parent BO could change, like when it is loaded, navigated, added, deleted, undone (maybe not all of these, but hopefully you get the idea). You don't need this here necessarily, unless loading the list could also change a monitored state (e.g. you have some object that requires an item selected within the list). Hope that makes sense.
Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.3K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
Oops, I've been sick and didn't read your post carefully enough. I thought that looked a lot like SF code Blush



The basic concept still holds though. You're calling it when the parent BO could change. If you need to also handle control states after the list is loaded, just call it after you call Requery():

Me.lvwExample.Requery()

Me.UpdateControlStates()


This should then get called after the UpdateObjectStates() is called and disable anything that is needed, based on the logic in your UpdateControlStates() method (or whatever you're calling it).
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
Greg McGuffey (04/29/2008)
The basic concept still holds though. You're calling it when the parent BO could change. If you need to also handle control states after the list is loaded, just call it after you call Requery()

Hi Greg,

Thanks for jump in.  Here is my code:

Private Sub InsuredCustomerBO1_Navigated(ByVal e As MicroFour.StrataFrame.Business.NavigatedEventArgs) Handles InsuredCustomerBO1.Navigated

     If Me.InsuredCustomerBO1.Count > 0 Then

          Me.Child_PolicyBO1.FillByParent()

          Me.lvPolicy.Requery()

     End If

     Me.UpdateFormStates()

End Sub

Private Sub InsuredCustomerBO1_CurrentDataTableRefilled() Handles InsuredCustomerBO1.CurrentDataTableRefilled

     Me.UpdateFormStates()

End Sub

Private Sub InsuredCustomerBO1_IsDirtyChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles InsuredCustomerBO1.IsDirtyChanged

     Me.UpdateFormStates()

End Sub

Private Sub UpdateFormStates()

     '-- Establish Locals

     Dim isAddAllowed As Boolean = Me.InsuredCustomerBO1.Count > 0

     '-- Set controls that require a parent record

     Me.cmdAdd_Policy.Enabled = isAddAllowed

End Sub

As you can see I am calling Me.UpdateFormStates in all places suggested by Trent, but the result is the same, the cmdAdd button is always Enabled when there is not record in the Parent BO.

Edhy Rijo

Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
Greg is still right....there is no reason to even allow the ListView to Requery itself if there is no parent record.  More than likely you already have something in the Navigated event of the parent BO that calls a Refresh on the child list...if there are no parent records, the you can just clear the list and ensure that your form method is called:

if MyParentBo.Count = 0 Then
    MyListView.Items.Clear()
End If

UpdateFormStates()


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