Forums
New posts
Search forums
What's new
New posts
New profile posts
Latest activity
Members
Current visitors
New profile posts
Search profile posts
C# Community
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
VB.NET
VB.NET General Discussion
"Value cannot be null" Weirdness
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="jwcoleman87, post: 170084, member: 50602"] 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 [xcode=vb] 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 [/xcode] 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: [xcode=vb] 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 [/xcode] 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? [/QUOTE]
Insert quotes…
Verification
Post reply
VB.NET
VB.NET General Discussion
"Value cannot be null" Weirdness
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.
Accept
Learn more…
Top
Bottom