C# フォームアプリケーションで作成しております。
現在、richtextbox上にテキストドキュメントの.txtファイルを読み込み、縦書きに表示したいと考えております。
以下のようにファイルを読み込んでおります
C#
1 private void button1_Click(object sender, EventArgs e) 2 { 3 if (sender == button1) 4 { 5 OpenFileDialog ofd = new OpenFileDialog(); 6 ofd.Filter = "テキストファイル|*.txt"; 7 8 if (ofd.ShowDialog() == DialogResult.OK) 9 { 10 StreamReader sr = new StreamReader(ofd.FileName, Encoding.GetEncoding("SHIFT_JIS")); 11 richTextBox1.Text = sr.ReadToEnd(); 12 } 13 } 14 }
縦書き表示を行うために、いろいろ検索しているのですが勉強不足によりうまくできません。
以下のコードを利用しようとしていましたがうまくできませんでした。
C#
1public void DrawVerticalString() 2{ 3 System.Drawing.Graphics formGraphics = this.CreateGraphics(); 4 string drawString = "Sample Text"; 5 System.Drawing.Font drawFont = new System.Drawing.Font("UD デジタル 教科書体 NP-B", 22); 6 System.Drawing.SolidBrush drawBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Black); 7 float x = 150.0F; 8 float y = 50.0F; 9 System.Drawing.StringFormat drawFormat = new System.Drawing.StringFormat(); 10 drawFormat.FormatFlags = StringFormatFlags.DirectionVertical; 11 formGraphics.DrawString(drawString, drawFont, drawBrush, x, y, drawFormat); 12 drawFont.Dispose(); 13 drawBrush.Dispose(); 14 formGraphics.Dispose(); 15}
どなたか、案などありましたらお願いいたします。

バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/09/28 07:26
2018/09/28 07:27 編集