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

Vb.net 如何在控制台应用程序中模拟PictureBox控件,vb.net,console,picturebox,emulation,Vb.net,Console,Picturebox,Emulation,有没有办法在控制台应用程序中模拟picturebox?我尝试过这种方法,但图像总是返回完全黑色: 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 假设您已经导入了显示表单所需的所

有没有办法在控制台应用程序中模拟picturebox?我尝试过这种方法,但图像总是返回完全黑色:

    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

假设您已经导入了显示表单所需的所有内容,请不要使用form.show方法。相反,使用
Application.Run(新表单1)
显示表单。这有一个更完整的答案

您可以在设计器中设计表单,按原样使用表单,或者将表单声明为新对象,并更改任何属性,然后将新对象传递给
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

你想用它做什么?您的代码在使用结束时处置控件。对于Size属性,您应该使用
New Size(255255)
。您说它是“返回的完全是黑色的”,但没有显示返回到的位置。你怎么知道图像是黑色的,或者你正在使用一些代码来渲染它而没有显示出来?我发布的代码就是一个例子,当然你会在“结束使用”之前返回picturebox