以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- [求助]这个代码我没看懂。想问问是哪出了问题 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=162823) |
-- 作者:zto001 -- 发布时间:2021/4/16 9:12:00 -- [求助]这个代码我没看懂。想问问是哪出了问题 http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=33931 这个应用下面这段代码老是出现这个问题,怎么回事? 版本:2020.5.29.8 版本:2020.5.29.8 x X 代码执行出错,错误信息: 代码执行出错,错误信息: system.ArgumentNullException:值不能为null。参数名: image ArgumentNullException:值不能为NULL。参数名:图像 在System.Drawing.Graphics.Drawlmage(lmage image, Int32 x, Int32 y,lnt32 width, Int32 height) 在系统.绘图.绘图.绘制(图像,Int 32 x,Int 32 y,Int 32宽度,Int 32高度) 在UserCode.Test0 在UserCode.Test 0 确定 确定 Forms("窗口1").StopRedraw() Dim onls As new List(of String) Dim lbpanel As WinForm.Panel=Forms("窗口1").Controls("列表") For Each con As WinForm.Control In lbpanel.Children If con.name.StartsWith("Panel_") And con.Visible Then onls.Add(con.name) End If Forms("窗口1").RemoveControl(con.name) Next con Dim groups As List(Of String) Dim Customers As List(Of String()) Dim pl As WinForm.Panel Dim la As WinForm.Label Dim pt As WinForm.Painter Dim i,j,k As Integer Dim s1 As String Dim gr As Graphics groups = DataTables("分组表").GetUniqueValues("组名<>\'\'","组名") For Each g As String In groups Customers=DataTables("用户列表").GetUniqueValues("分组=\'" & g & "\'","用户名","昵称","头像","ID","状态") la = Forms("窗口1").CreateControl("label_" & g, ControlTypeEnum.label) la.Dock = System.Windows.Forms.DockStyle.top la.text=g & "[" & customers.Count & "]" la.AutoSize=False la.TextAlign=ContentAlignment.MiddleLeft Forms("窗口1").Controls("列表").AddControl(la) pl = Forms("窗口1").CreateControl("Panel_" & g, ControlTypeEnum.Panel) pl.Dock = System.Windows.Forms.DockStyle.top pl.BorderStyle=BorderStyle.none i=customers.Count*20 pl.Height=i pl.Visible=onls.Contains("Panel_" & g) Forms("窗口1").Controls("列表").AddControl(pl) For Each c() As String In customers pt =Forms("窗口1").CreateControl("custom_" & c(3), ControlTypeEnum.Painter) pt.height=20 pt.BorderStyle = BorderStyle.none pt.Dock = System.Windows.Forms.DockStyle.top pl.AddControl(pt) s1=c(0) & "(" & c(1) & ")" gr= pt.Graphics Dim fnt As New Font("黑体",10,FontStyle.Bold) gr.DrawString(s1,fnt,Brushes.black,30,2) \'定义启始为止 If c(2) IsNot Nothing Then If c(4)="在线" Then gr.DrawImage(getImage(c(2)),2,2,16,16) Else System.Windows.Forms.ControlPaint.DrawImageDisabled(gr,getImage(c(2)), 2, 2, Color.Transparent) End If If c(4)="禁用" Then Dim pn As New Pen(Color.black,3) gr.DrawLine(pn,2,10,18,10) End If End If pt.Repaint() Next c Next g Forms("窗口1").ResumeRedraw() |
-- 作者:有点蓝 -- 发布时间:2021/4/16 9:20:00 -- system.ArgumentNullException:值不能为null。参数名: image ArgumentNullException:值不能为NULL。参数名:图像 在System.Drawing.Graphics.Drawlmage(lmage image, Int32 x, Int32 y,lnt32 width, Int32 height) 意思就是上面的image参数不能传入空值,估计是下面代码问题 gr.DrawImage(getImage(c(2)),2,2,16,16) getImage(c(2))获取不到图片,要么c(2)这个路径不存在,或者不是图片 dim img as image = getImage(c(2)) if img is nothing then msgbox("不存在")
|