Lookup drowdown not changed to default after BO.Clear()

Author Message
 Posted 6/6/2013 9:02:24 AM
StrataFrame Novice

StrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame Novice

Group: StrataFrame Users
Last Login: 5/8/2020 7:04:55 AM
Posts: 97, Visits: 499
Hello all, 

Maybe someone can suggest a workaround for this problem: I have a maintenance screen where one of the fields is edited using a SF lookup dropdown list. Editing works fine in everyway, but when I do a BO.Clear() the selected Text is still visible in the dropdown. The control is disabled as it should be when the BO is Idle but, the Text of the previously selected value is still visible. I would like it show the Top Most Item or at least display no selection (blank). 

I have attached a sample project that demonstrates the problem. 

Thank You, 
Govinda

Tags:
Post #32092
Add to Twitter Add to Facebook
 Posted 6/6/2013 9:05:33 AM
StrataFrame Novice

StrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame Novice

Group: StrataFrame Users
Last Login: 5/8/2020 7:04:55 AM
Posts: 97, Visits: 499
Oops

 TestBoundDDL.zip (1 view, 69.41 KB)
Post #32093
Add to Twitter Add to Facebook
 Posted 6/6/2013 9:35:15 AM
StrataFrame Developer

StrataFrame DeveloperStrataFrame DeveloperStrataFrame DeveloperStrataFrame DeveloperStrataFrame DeveloperStrataFrame DeveloperStrataFrame DeveloperStrataFrame DeveloperStrataFrame Developer

Group: StrataFrame Developers
Last Login: 5/16/2018 3:20:37 AM
Posts: 2,982, Visits: 2,482
Is that posted project a solution to your problem? 
Post #32094
Add to Twitter Add to Facebook
 Posted 6/6/2013 9:39:45 AM
StrataFrame Novice

StrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame Novice

Group: StrataFrame Users
Last Login: 5/8/2020 7:04:55 AM
Posts: 97, Visits: 499
No. I neglected to attach the project on the initial post, so I replied and attached it.
Post #32097
Add to Twitter Add to Facebook
 Posted 6/7/2013 4:31:49 AM
StrataFrame Developer

StrataFrame DeveloperStrataFrame DeveloperStrataFrame DeveloperStrataFrame DeveloperStrataFrame DeveloperStrataFrame DeveloperStrataFrame DeveloperStrataFrame DeveloperStrataFrame Developer

Group: StrataFrame Developers
Last Login: 5/16/2018 3:20:37 AM
Posts: 2,982, Visits: 2,482
OK, the problem is that the RemoveBinding() method in the BusinessLayer class cannot force the text back to String.Empty because none of the items in the data source matches that string.  

So, I've modified the RemoveBinding() method to handle the situation better.  Your options are:

1) Manually call this.comboBox1.SelectedIndex = 0; when you call bo.Clear();
2) Change the BusinessLayer.vb source code and recompile it:
Private Sub RemoveBinding(ByVal ControlToRefresh As Control, ByVal PropertyName As String)            '-- Establish locals            Dim loPropInfo As PropertyInfo             '-- Check to see if the bindings have already been removed            If ControlToRefresh.DataBindings.Count > 0 Then                '-- If there are data bindings, but no data, then clear the data bindings to prevent errors                ControlToRefresh.DataBindings.Clear()                 '-- Set the property value                Dim combo As System.Windows.Forms.ComboBox = TryCast(ControlToRefresh, System.Windows.Forms.ComboBox)                If combo IsNot Nothing Then                    '-- We need to clear the combo box                    '-- First try to set the text on the combo box                    combo.Text = String.Empty                     '-- If the text could not be set, then either clear the selected value or set to the top index if it has a data source                    If Not String.IsNullOrEmpty(combo.Text) Then                        If combo.DataSource Is Nothing Then                            '-- Clear the selected value                            combo.SelectedValue = Nothing                        ElseIf combo.Items.Count > 0 Then                            '-- Set to the top index                            combo.SelectedIndex = 0                        End If                    End If                Else                    '-- Get the property info                    loPropInfo = TypePropertyCache.GetPropertyInfo(ControlToRefresh.GetType(), PropertyName)                     '-- Clear out the value                    loPropInfo.SetValue(ControlToRefresh, GetSystemTypeDefaultValue(loPropInfo.PropertyType), Nothing)                End If            End If        End Sub
You can replace the whole RemoveBinding() method with that.  The BusinessLayer.vb file is in the MicroFour StrataFrame Business project.  The code starts on line 3535.
Post #32101
Add to Twitter Add to Facebook
 Posted 6/7/2013 4:49:39 AM
StrataFrame Novice

StrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame Novice

Group: StrataFrame Users
Last Login: 5/8/2020 7:04:55 AM
Posts: 97, Visits: 499
Thank You, Ben!

I will use your code. 

Govinda
Post #32102
Add to Twitter Add to Facebook


Similar Topics

Expand / Collapse

Reading This Topic

Expand / Collapse

Site Map - Home - My Account - Forum - About Us - Contact Us - Try It - Buy It

Microsoft, Visual Studio, and the Visual Studio logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries.