Validation within a Combobox


Author
Message
Edhy Rijo
E
StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
In a childform dialog, I have a textbox txtItemPrice that needs to be updated from a combobox items lookup, I have the following code in the combobox.SelectedIndexChanged:

Private Sub cboItemName_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboItemName.SelectedIndexChanged

     '-- Look the item price and if found and there is a current price, ask

     ' the user if he/she wants to overwrite the Item Price.

     If Me.BizItems_Lookup.Count > 0 Then

          If Me.BizItems_Lookup.SeekToPrimaryKey(Me.bizSC_AppliancesItems1.FK_Items) Then

               If Me.bizSC_AppliancesItems1.ItemPrice <= 0 Then

                    Me.bizSC_AppliancesItems1.ItemPrice = Me.BizItems_Lookup.ItemPrice

               Else

                    If Me.ShowMessageByKey("ApplianceItems_OverwriteItemPrice", Me.bizSC_AppliancesItems1.ItemPrice, Me.BizItems_Lookup.ItemPrice) = MicroFour.StrataFrame.Messaging.MessageFunctionType.Yes Then

                         Me.bizSC_AppliancesItems1.ItemPrice = Me.BizItems_Lookup.ItemPrice

                    End If

               End If

          End If

          Me.bizSC_AppliancesItems1.Refresh("ItemPrice")

     End If

End Sub

The problem is that when the ChildFormDialog is being loaded, the cboItemName_SelectedIndexChanged method is being fired several times, even when the form has not even shown.  In VFP I would simply put the code in the combobox.Valid(), how to get the same effect as the VFP combobox.Valid() or what event should be used in the combo in this scenario ?

Edhy Rijo

Replies
Edhy Rijo
E
StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Geoff, Trent,

Thanks a lot.  This is an interesting approach on how to handle this situation and actually I ended up using the same concept for another case in a DropDown event and it worked just fine.

One more clarification for the combobox, which is the preferable event to handle in a validation case like this, the SelectedIndexChanged or SelectedValueChanged event?

I tried both with the _FormIsLoading approach and they both worked, but I like to be consistent with my coding and be clear as to which event to use for the same common validation.



Edhy Rijo

Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
It really depends on what I am trying to do, but I generally use the SelectedIndexChanged event more than the SelectedValueChanged since certain errors may have to be trapped on the SelectedValue changed if the combo has not yet been populated, loaded, etc. depending on instatiation orders.  Using the SelectedIndexChanged generally reduces the number of "holes" that have to be plugged.
Edhy Rijo
E
StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Great! Thanks!

Edhy Rijo

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Threaded View
Threaded View
Edhy Rijo - 17 Years Ago
Geoff Hirst - 17 Years Ago
Trent L. Taylor - 17 Years Ago
Edhy Rijo - 17 Years Ago
Trent L. Taylor - 17 Years Ago
                         Great! Thanks!
Edhy Rijo - 17 Years Ago

Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search