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


Author
Message
Govinda Berrio
Govinda Berrio
StrataFrame User (132 reputation)StrataFrame User (132 reputation)StrataFrame User (132 reputation)StrataFrame User (132 reputation)StrataFrame User (132 reputation)StrataFrame User (132 reputation)StrataFrame User (132 reputation)StrataFrame User (132 reputation)StrataFrame User (132 reputation)
Group: StrataFrame Users
Posts: 94, Visits: 481
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
Govinda Berrio
Govinda Berrio
StrataFrame User (132 reputation)StrataFrame User (132 reputation)StrataFrame User (132 reputation)StrataFrame User (132 reputation)StrataFrame User (132 reputation)StrataFrame User (132 reputation)StrataFrame User (132 reputation)StrataFrame User (132 reputation)StrataFrame User (132 reputation)
Group: StrataFrame Users
Posts: 94, Visits: 481
Oops
Attachments
TestBoundDDL.zip (115 views, 69.00 KB)
StrataFrame Team
S
StrataFrame Developer (3.1K reputation)StrataFrame Developer (3.1K reputation)StrataFrame Developer (3.1K reputation)StrataFrame Developer (3.1K reputation)StrataFrame Developer (3.1K reputation)StrataFrame Developer (3.1K reputation)StrataFrame Developer (3.1K reputation)StrataFrame Developer (3.1K reputation)StrataFrame Developer (3.1K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
Is that posted project a solution to your problem? 
Govinda Berrio
Govinda Berrio
StrataFrame User (132 reputation)StrataFrame User (132 reputation)StrataFrame User (132 reputation)StrataFrame User (132 reputation)StrataFrame User (132 reputation)StrataFrame User (132 reputation)StrataFrame User (132 reputation)StrataFrame User (132 reputation)StrataFrame User (132 reputation)
Group: StrataFrame Users
Posts: 94, Visits: 481
No. I neglected to attach the project on the initial post, so I replied and attached it.
StrataFrame Team
S
StrataFrame Developer (3.1K reputation)StrataFrame Developer (3.1K reputation)StrataFrame Developer (3.1K reputation)StrataFrame Developer (3.1K reputation)StrataFrame Developer (3.1K reputation)StrataFrame Developer (3.1K reputation)StrataFrame Developer (3.1K reputation)StrataFrame Developer (3.1K reputation)StrataFrame Developer (3.1K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
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.
Govinda Berrio
Govinda Berrio
StrataFrame User (132 reputation)StrataFrame User (132 reputation)StrataFrame User (132 reputation)StrataFrame User (132 reputation)StrataFrame User (132 reputation)StrataFrame User (132 reputation)StrataFrame User (132 reputation)StrataFrame User (132 reputation)StrataFrame User (132 reputation)
Group: StrataFrame Users
Posts: 94, Visits: 481
Thank You, Ben!

I will use your code. 

Govinda
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