jwcoleman87
Well-known member
- Joined
- Oct 4, 2014
- Messages
- 124
- Programming Experience
- Beginner
I'm having an issue when trying to setup a data source for a set of combo boxes. I've found success, but only after working around an error stating that "value cannot be null"
It took my a while to find the source of this being that the breakpoint after the exception was placed a few lines after what I found to actually be causing the error.
I have this class
This class works really great with one exception, when I try to set the datasource in "initialize controls" (which is called in the Mybase.New(string, object) constructor) I get errors and other weirdness (like invisible controls that still have events, I.E -> I can hit the drop down arrow of the combo box but nothing appears).
As a workaround I have set the datasources outside of this class like so:
This works just fine.
Again the error only occurs if I try to set the datasource within the FailureFixTab object, "value cannot be null". The breakpoint ends up getting set at the next step after the constructor these controls are initialized in.
Any ideas what could be broken here?
It took my a while to find the source of this being that the breakpoint after the exception was placed a few lines after what I found to actually be causing the error.
I have this class
Public Class FailureFixTab : Inherits ActionTab Sub New(ByRef ParentForm As Object) MyBase.New("FailureFix", ParentForm) End Sub Protected Overrides Sub InitializeControls() Try Dim cbSelectedFailure As New ComboBox With {.Parent = Me.ChildContainerControl, .SelectedItem = Nothing} Dim cbSelectedFix As New ComboBox With {.Parent = Me.ChildContainerControl, .SelectedItem = Nothing} Dim btnSaveFailureFix As New Button With {.Name = "btnSaveFailureFix", .Parent = Me.ChildContainerControl, .Text = "Save"} Catch ex As Exception End Try End Sub Protected Overrides Sub InitializeEventHandlers() Try AddHandler ChildContainerControl.Controls.Find("btnSaveFailureFix", True)(0).Click, AddressOf Me.ActionEvent Catch ex As Exception End Try End Sub Protected Overrides Sub ActionEvent(sender As Object, e As EventArgs) If IsNothing(ParentFormReference.RepairInformation) Then MsgBox("RepairInformation is empty!") Else Dim rc As New RepairControl rc.SetStatusAndAssignment(ParentFormReference.RepairInformation.SerialNumber, ParentFormReference.User, ParentFormReference.RepairInformation.Status) End If End Sub End Class
This class works really great with one exception, when I try to set the datasource in "initialize controls" (which is called in the Mybase.New(string, object) constructor) I get errors and other weirdness (like invisible controls that still have events, I.E -> I can hit the drop down arrow of the combo box but nothing appears).
As a workaround I have set the datasources outside of this class like so:
Dim addcommentstab As New CommentTab(Me) With {.Text = "Add Comments"} Dim AddFailureFixTab As New FailureFixTab(Me) With {.Text = "Enter Failure/Fix"} TabControl1.TabPages.Add(addcommentstab) TabControl1.TabPages.Add(AddFailureFixTab) Dim rc As New RepairControl DirectCast(AddFailureFixTab.ChildContainerControl.Controls(0), ComboBox).DataSource = rc.GetFailureFix(1) DirectCast(AddFailureFixTab.ChildContainerControl.Controls(1), ComboBox).DataSource = rc.GetFailureFix(2) DirectCast(AddFailureFixTab.ChildContainerControl.Controls(1), ComboBox).SelectedItem = Nothing
This works just fine.
Again the error only occurs if I try to set the datasource within the FailureFixTab object, "value cannot be null". The breakpoint ends up getting set at the next step after the constructor these controls are initialized in.
Any ideas what could be broken here?