Click here to Skip to main content
15,891,708 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I dynamically create a bunch of tabs for a TabStrip control, with code like
SubsTabControl.TabPages.Add(New TabPage() With {.Text = s.Id, .Tag = s})

yet when I try and access the Tag property in subsequent code, it is null? Why is this? The line above is in GenerateTabs, the null reference occurs here:
VB
GenerateTabs()

If (SubsTabControl.TabCount > 0) Then
    With SubsTabControl.SelectedTab
        Dim tab = SubsTabControl.TabPages.Item(SubsTabControl.SelectedIndex)
        Dim subProcess As SubProcess = DirectCast(.Tag, SubProcess)
        .Controls.Clear()
        .Controls.Add(GridControl)
        GridControl.ProcessDesc = subProcess.Process.Desc
        GridControl.SubId = subProcess.Id
    End With
End If
Posted
Comments
Sergey Alexandrovich Kryukov 21-Sep-12 18:12pm    
Is this the only place where you create a tag? After all, you can track it all under debugger. You did not provide full information, apparently...
--SA
ledtech3 21-Sep-12 19:53pm    
with out seeing the full code, would the ".Controls.Clear()" clear what was created above it?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900