If Rtext.Text = "*" Then MsgBox("テキストを入力してください") Else If Mmax < 50 Then Te = Rtext.Text Me.mozi = New PictureBox() Me.mozi.Name = "Text1" Me.mozi.Text = Te Me.mozi.AutoSize = False Me.mozi.Size = New Size(150, Rtext.TextLength * 40) '描画先とするImageオブジェクトを作成する Dim canvas As New Bitmap(Rtext.Width, Rtext.Height) 'ImageオブジェクトのGraphicsオブジェクトを作成する Dim g As Graphics = Graphics.FromImage(canvas) Dim drawString As String = Rtext.Text 'Fontオブジェクトの作成(太字にする) Dim fnt As New Font("@ 明朝", 24, FontStyle.Bold) 'StringFormatを作成 Dim sf As New StringFormat() '縦書きにする sf.FormatFlags = StringFormatFlags.DirectionVertical '縦書きにして、右から左に表示する ''sf.FormatFlags = StringFormatFlags.DirectionVertical Or _ 'StringFormatFlags.DirectionRightToLeft() fnt = Rtext.Font Dim color As Color Dim bc As SolidBrush = New SolidBrush(Rtext.ForeColor) '文字を表示 g.DrawString(drawString, fnt, bc, 0.0F, 0.0F, sf) 'リソースを解放する sf.Dispose() fnt.Dispose() g.Dispose() 'PictureBox1に表示する mozi.Image = canvas Me.mozi.BackColor = Color.Transparent mozi.ContextMenuStrip = ContextMenuStrip1 AddHandler mozi.MouseDown, AddressOf mozi_MouseDown AddHandler mozi.MouseMove, AddressOf mozi_MouseMove AddHandler mozi.MouseUp, AddressOf mozi_MouseUp AddHandler mozi.Click, AddressOf mozi_Click AddHandler mozi.DoubleClick, AddressOf mozi_DoubleClick Panel1.Controls.Add(Me.mozi) mozi.BringToFront() Rtext.Clear() Mmax = Mmax + 1 Else MsgBox("これ以上配置できません", 16) End If End If