Reputation: 15
i try add Textbox in panel at runtime but i get error:
An unhandled exception of type 'System.NullReferenceException' occurred in Judge.exe
Additional information: Object reference not set to an instance of an object.
and my code is:
Dim nl As New TextBox
AddHandler nl.LostFocus, AddressOf lost_focus
nl.Focus()
Panel1.Container.Add(nl)
and i use sub to add it and i call it from other form and its UserControl.
thanks.
Upvotes: 0
Views: 88
Reputation: 6856
Panel1.Container
is probably wrong. Try Panel1.Controls.Add(nl)
.
Upvotes: 2