ListView activate Add/Edit/delete/ buttons when select an item of the list


ListView activate Add/Edit/delete/ buttons when select an item of the...
Author
Message
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

I'm having a problem similar to one reported before by Edhy:

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?

I read all the answers and found the solution for the Add button to remain disabled, but I found a new problem; if I have some elements on the list and clic on one of them, the Add/Edit/Delete buttons get active, the code for handle the buttons state is the same so these buttons should not be enabled if the EditState of the form is not enabled.

Private Sub SetPreciosProveedorButtonState()

' Sets the enabled state of the buttons

'-- Establish Locals

Dim llSelected As Boolean = Me.lvProveedores.SelectedItems.Count > 0

'-- See if the buttons can be enabled

Me.tsBtnNuevoPrecioProveedor.Enabled = Me.ProductosBO1.EditingState <> BusinessEditingState.Idle

Me.tsBtnEditarPrecioProveedor.Enabled = llSelected AndAlso (Me.ProductosBO1.EditingState <> BusinessEditingState.Idle)

Me.tsBtnBorrarPrecioProveedor.Enabled = llSelected AndAlso (Me.ProductosBO1.EditingState <> BusinessEditingState.Idle)

End Sub

Looking a solution I make the same approach of the old CRM Sample Application, in the Customers form, you handle the buttons by code and not by the properties of the ListView, using this the buttons remain disabled until the form editing state is enabled. I know these sample was made before the Listview has the properties for handle directly the Add/Edit/Delete buttons.

I believe can be a small bug in the ListView, but of course can be an error in my form.

Do you have any 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,

I think that was fixed before.  What version of SF are you using?

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
I don't think this is a bug.  Like Edhy asked, what version of SF are you using?
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 Trent , Edhy

I'm using tle last one (the beta).

Regards

Smile Everything is possible, just keep trying...

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
Well, then this must be something within your code here.  Please post a sample reproducing as I know that this works, so there is most likely something else in the forumula here.
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 Trent

I don't think is my code, I add a new form named CustomersManteinance2 to the CRMSample application, add some controls and the ListView, is pretty much same as the original, the main difference is in the ListView I use the properties to handle the Add/Edit/Delete buttons.

If you give a try you will notice first it needs add the SetCreditCardButtonState() after requery the list in the CustomersBO_Navigated event, for prevent the Add button activates.

Second, the problem I have in my application, if you select an item of the List of credit cards the three buttons activate even the EditState of the form is not in edit mode.

In my application I have the same here, and as the sample if I use code for the ListView properties all works, but if I use the properties not.

In the main form I add a buttom named Customers 2 for show the form I did.

Hope can find a solution,

Regards

Smile Everything is possible, just keep trying...

Attachments
CRMApplication.zip (130 views, 1.00 MB)
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,

I took a quick view of your CustomerMaintenance2.vb form and here are the changes you need to made to make it work:

  1. Remove all code for the method SetCreditCardButtonState, you don't need it.
  2. Since you are working with 2 related tables, the Undo needs to be synch with all BO's editing state, so set the form.IncludeInFormUndoType = AllBusinessObjects, so when you change a credit card record it will enable the form's toolbar Undo button.
  3. Replace the CustomersBO1_Navigated event with the code below.
  4. Add the new lstCards_ChildFormResults event as the code below.
  5. Re-read carefully the documentation about the ListView and also the changed information in the posted release forum, they will help you out a lot.  The listview is one of the SF control that has been greatly enhanced and will continue to be.

Private Sub CustomersBO1_Navigated(ByVal e As MicroFour.StrataFrame.Business.NavigatedEventArgs) Handles CustomersBO1.Navigated

     '-- Make sure there are records in the customers BO, otherwise

     ' an error will occur.

     If CustomersBO1.Count > 0 Then

          '-- Load the customer credit cards

          Me.CustomerCreditCardsBO1.FillByParentPrimaryKey(CustomersBO1.cust_pk)

     End If

     '-- Requery the credit card list    

     Me.lstCards.Requery()

End Sub

 

Private Sub lstCards_ChildFormResults(ByVal sender As System.Object, ByVal e As MicroFour.StrataFrame.UI.Windows.Forms.ListViewChildFormResultsEventArgs) Handles lstCards.ChildFormResults

     If e.Results = Windows.Forms.DialogResult.Cancel Then

          Me.CustomerCreditCardsBO1.RestoreCurrentDataTableSnapshot("", True)

     Else

          e.Requery = True

     End If

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 Edhy

It's not working, following the steps you give me.

1) The Add button it's enabled all time, these button should be enabled only when the user goes to Edit mode of the record

2) Adding the the AllBusinessObjects in the Undo nicely Wink enable the Undo if some change it's done, thats good, but main problem stands, selecting an item of the list activates the edit/delete buttons, even regardless the user is in Editing mode or not.

The original samples is exactly what I'm trying to do, the buttons are not enabled until user goes to Edit mode click in the Edit button of the form, maybe the problem is that I assume that the properties of the ListView should handle the edit state of the buttons so we not have to add code anymore; using the code of the original sample works fine.

The last about the ChildFormResults, I forgot to add it, the only idea was show to Trent the problem with the edit state in the buttons, thanks any way I will have to look why you use this:

Me.CustomersBO1.RestoreCurrentDataTableSnapshot("", True)

And I use this:

Me.CustomersBO1.RestoreCurrentDataTableSnapshot(False)

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
Juan Carlos Pazos (01/29/2009)

1) The Add button it's enabled all time, these button should be enabled only when the user goes to Edit mode of the record[/

No really, I don't think that is how the functionality of the listview has been designed.  As long as there is a parent record, the ListView Add button will be enable so you can add child records regardless of the Edit mode, same functinality as with the parent record and the maintenance toolbar, you can Add records without having to click the Edit button.  Take a look at the ListView.vb UpdateObjectStates() method in the MicroFour.StrataFrame.UI.WinForms Controls assembly.

2) ...but main problem stands, selecting an item of the list activates the edit/delete buttons, even regardless the user is in Editing mode or not.

Again this is the default behavior, look at the source code.  I have not used the Edit mode functionality in my applications yet, but I think that may be an enhancement to take into consideration the Edit mode functionality.

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
Edhy

Thanks for make me clear those points.

Regards

Smile Everything is possible, just keep trying...

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