Foxtable(狐表)用户栏目专家坐堂 → picturebox中动态加入控件,遍历children,没找到控件?


  共有2047人关注过本帖树形打印复制链接

主题:picturebox中动态加入控件,遍历children,没找到控件?

帅哥哟,离线,有人找我吗?
foxrobbie
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:婴狐 帖子:41 积分:917 威望:0 精华:0 注册:2016/8/25 16:26:00
picturebox中动态加入控件,遍历children,没找到控件?  发帖心情 Post By:2025/1/11 1:55:00 [显示全部帖子]

        Dim p_country As WinForm.picturebox = e.Form.Controls("Pb_国家")
        Dim countrylist As String = ""
        For Each c As WinForm.PictureBox In p_country.children
            countrylist = countrylist & "," & c.Name
        Next
红色的部分编译没问题,但完全没有执行

 回到顶部
帅哥哟,离线,有人找我吗?
foxrobbie
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:婴狐 帖子:41 积分:917 威望:0 精华:0 注册:2016/8/25 16:26:00
  发帖心情 Post By:2025/1/11 12:19:00 [显示全部帖子]

Dim fm As WinForm.Form = forms(args(0)) '窗口名
Dim PName As String = args(1) 'picturebox名

Dim pa As WinForm.PictureBox= fm.Controls(PName)
Dim pbx As WinForm.PictureBox
For Each p As String In ps
    pbx = fm.CreateControl(p, ControlTypeEnum.PictureBox)
    pa.AddControl(pbx)
    pbx.ToolTip = p
    pbx.Width = 53
    pbx.Height = 39
    pbx.Left = x
    pbx.Top = y
    If p <> "" Then
    pbx.ImageFile = p & ".png"
    Else
    pbx.ImageFile =  "问号.png"
    End If
    pbx.SizeMode = ImageSizeMode.Zoom    
     x = x + 60
    If x+60 > pa.Width Then
        x = 2
        y = y + 42
    End If
Next

 回到顶部