如何在控制台应用程序中模拟PictureBox控件

时间:2013-10-31 13:07:32

标签: vb.net console picturebox emulation

有没有办法在控制台应用程序中模拟图片框?我试过这种方式,但图像总是完全变黑:

    Using P As New PictureBox
        P.Size = New Point(255, 255)
        P.Image = New Bitmap(255, 255) 'I did set a real image, but I didn't for the sake this example
    End Using

1 个答案:

答案 0 :(得分:0)

假设您已导入显示表单所需的所有内容,请不要使用form.Show方法。而是使用Application.Run(New Form1)来显示表单。这个post有一个更完整的答案。

您可以在设计器中设计表单,按原样使用它,或将其声明为新对象并更改任何属性并将新对象传递给Run方法。

Imports System.Drawing
Imports System.Windows.Forms
Module Module1

    Sub Main()
        Dim newform1 As New Form1
        newform1.PictureBox1.Image = New Bitmap("MyImageFile")
        Application.Run(newform1)
        Console.ReadLine()
    End Sub

End Module
相关问题