Flowlayoutpanel child controls?

Zexor

Well-known member
Joined
Nov 28, 2008
Messages
520
Programming Experience
3-5
I have a flowlayoutpanel, and i am dynamically adding empty pictureboxes to it. Then do a bunch of things. Then how do i add image to a certain pictureboxes in the panel? can i refer to the picturebox by name?
 
Yes, Tag property type is Object, you can put anything in there. When getting it out again use CType/DirectCast to cast to the actual type it is.
 
I read that DirectCast is better than CType? But the compiler always do type convert with CType? Is DirectCast better?
 
DirectCast will only work if the object is the specific type that you're casting as. CType will also perform conversions in cases where it's supported. For instance, this will work:
VB.NET:
Dim o As Object = "100"
Dim n As Integer = CType(o, Integer)
while this will not:
VB.NET:
Dim o As Object = "100"
Dim n As Integer = DirectCast(o, Integer)
If you're casting, use DirectCast.
 

Latest posts

Back
Top