以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- [求助]可否设置Panel控件出现网格,Panel内控件导出为图片 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=169384) |
-- 作者:小美菜 -- 发布时间:2021/6/14 18:57:00 -- [求助]可否设置Panel控件出现网格,Panel内控件导出为图片 [求助]可否设置Panel控件出现网格,Panel内控件导出为图片(整个Panel内控件) |
-- 作者:有点蓝 -- 发布时间:2021/6/14 21:47:00 -- 网格可以设置背景图实现 Dim p As WinForm.Panel = e.Form.Controls("Panel1") p.basecontrol.BackgroundImage = getimage("5SUR63KA0RBT0031.jpg") p.basecontrol.BackgroundImageLayout = 3 保存图片参考 Dim panel1 = e.Form.Controls("Panel1").basecontrol Dim NewBitmap As new Bitmap(cint(panel1.Width), cint(panel1.Height)) panel1.DrawToBitmap(NewBitmap, new Rectangle(0, 0,NewBitmap.Width, NewBitmap.Height)) NewBitmap.Save("D:\\问题\\控件\\111.jpg", System.Drawing.Imaging.ImageFormat.Jpeg) NewBitmap.Dispose() |
-- 作者:小美菜 -- 发布时间:2021/6/15 8:34:00 -- 谢谢蓝老师,请问网格线图片有什么要求?5SUR63KA0RBT0031.jpg这个文件不是内置的吧,我用了,没有显示网格!另外,设置好网格线后要关闭网格线,又怎么操作?谢谢 |
-- 作者:有点蓝 -- 发布时间:2021/6/15 8:49:00 -- 改为自己需要的任意图片即可,上面代码仅仅是做个例子,不存在什么内置图片 关闭就清空背景图即可
|
-- 作者:小美菜 -- 发布时间:2021/6/15 22:51:00 -- 蓝老师,你的方法高出来的网格线,不是太好,我用下列方法,可是只有横线(也就是第二个for循环)可以显示,第一个显示一个点,我查过PnlDraw 、dWidth都是正常的,请问第一个for循环,为何绘制的是一个点 Dim PnlDraw As WinForm.Panel = e.Form.Controls("PnlDraw") Dim dWidth As Integer = e.Form.Controls("CombWidth").text For i As Integer = 1 To Tables(e.Form.Name & "_TblTitle").Cols.Count - 1 Dim oLine As WinForm.Line = e.Form.CreateControl("Lny" & i , ControlTypeEnum.Line) oLine.LineColor = Color.White oLine.TopMost = True oLine.DashStyle = DashStyleEnum.Dot oLine.SetBounds(i * dWidth , 0 , 1 , PnlDraw.Height ) PnlDraw.AddControl(oLine) Next For i As Integer = 1 To Tables( e.Form.Name & "_TblTask").Rows.Count - 1 Dim oLine As WinForm.Line = e.Form.CreateControl("Lnx" & i , ControlTypeEnum.Line) oLine.SetBounds(0 , i * 20 , PnlDraw.Width , 1) oLine.TopMost = True oLine.DashStyle = DashStyleEnum.Dot oLine.LineColor = Color.White PnlDraw.AddControl(oLine) Next |
-- 作者:有点蓝 -- 发布时间:2021/6/15 23:04:00 -- 代码放在什么事件? |
-- 作者:有点蓝 -- 发布时间:2021/6/15 23:06:00 -- 调试一下: msgbox(PnlDraw.Height) For i As Integer = 1 To Tables(e.Form.Name & "_TblTitle").Cols.Count - 1 Dim oLine As WinForm.Line = e.Form.CreateControl("Lny" & i , ControlTypeEnum.Line) oLine.LineColor = Color.White oLine.TopMost = True oLine.DashStyle = DashStyleEnum.Dot oLine.SetBounds(i * dWidth , 0 , 1 , PnlDraw.Height ) msgbox(oLine.Width & "," & oLine.Height) PnlDraw.AddControl(oLine) msgbox(oLine.Width & "," & oLine.Height) Next |
-- 作者:小美菜 -- 发布时间:2021/6/16 11:11:00 -- msgbox(i & "A," & oLine.LEFT & "," & oLine.ToP & "," & oLine.Width & "," & oLine.Height) PnlDraw.AddControl(oLine) msgbox(i & "B," & oLine.LEFT & "," & oLine.ToP & "," & oLine.Width & "," & oLine.Height) 结果显示:{1A,30,0,1,625;1B,30,0,1,625} {2A,60,0,1,625;2B,60,0,1,625} 从显示结果看没问题呀!代码放在一个Button的click事件中 |
-- 作者:有点蓝 -- 发布时间:2021/6/16 11:16:00 -- 把线条宽度设置大了看看 oLine.SetBounds(i * dWidth , 0 , 5, PnlDraw.Height )
|