Imports System.Drawing.Imaging Imports System.IO Public Class Form1 Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load Dim wmf As Metafile Using bmp As New Bitmap(1, 1), gw = Graphics.FromImage(bmp) Dim hdc = gw.GetHdc() wmf = New Metafile(New MemoryStream(), hdc, New Rectangle(0, 0, 50, 50), MetafileFrameUnit.Pixel, EmfType.EmfPlusDual) gw.ReleaseHdc(hdc) End Using Using g = Graphics.FromImage(wmf) g.Clear(Color.White) For i = 0 To 24 If i Mod 2 = 0 Then Dim x = i Mod 5 Dim y = i \ 5 Dim r As New Rectangle(x, y, 10, 10) g.FillRectangle(Brushes.Red, (i Mod 5) * 10, (i \ 5) * 10, 10, 10) End If Next g.Flush() End Using PictureBox1.BackgroundImageLayout = ImageLayout.Stretch PictureBox1.BackgroundImage = wmf End Sub End Class