注册 登录
编程论坛 VB.NET论坛

请问在.net里面怎么实现在picturebox里面画线啊?我在窗体里面可以实现,但是picturebox里不可以,为什么?

QYCqyc 发布于 2012-11-06 09:48, 1176 次点击
请问在.net里面怎么实现在picturebox里面画线啊?我在窗体里面可以实现,但是picturebox里不可以,为什么?
3 回复
#2
mmxo2012-11-22 22:27
不可能不可以的,如下:
程序代码:
void PictureBox_Paint(object sender, PaintEventArgs e)
        {
            var g = Pb.CreateGraphics();
            g.SmoothingMode = SmoothingMode.AntiAlias;
            g.Clear(Pb.BackColor);
            g.DrawLine(new Pen(Color.Black, 2f), 0, 0, Pb.Width, Pb.Height);
        }

 
#3
凯子3312012-12-07 20:50
我也遇到过同样问题  但是我的程序是从VB6.0中移植过来的  但是PictureBox控件的不能升级
#4
woerma20122013-01-06 18:32
我是新手,今天刚好看到一篇类似的教程,借用下:

Private Sub btnDrawborder_Click(sender As Object, e As EventArgs) Handles btnDrawborder.Click
        Dim objGraphics As Graphics
        objGraphics = Me.CreateGraphics
        objGraphics.Clear(System.Drawing.SystemColors.Control)
        objGraphics.DrawRectangle(System.Drawing.Pens.Red, picShowPicture.Left - 1, _
                                    picShowPicture.Top - 1, picShowPicture.Height + 1, _
                                    picShowPicture.Width + 1)
        objGraphics.Dispose()
    End Sub

希望能对你有帮助

1