準備
(なし)
デザイン
- フォーム (Form1) にボタン (button1) を配置します。
- フォーム (Form1) にリッチテキストボックス (richTextBox1) を配置します。
サンプルコード (C#)
namespace WinFormsApp1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
for (int i = 0; i < 100; i++)
{
richTextBox1.SelectionColor = Color.FromArgb(255, 255 - i, 255 - i, 255);
richTextBox1.AppendText("Hello, World! ");
}
}
}
}
解説
リッチテキストボックスに文字列を赤色で追加しています。
結果
動作確認環境
Visual Studio 2022 Professional (.NET8 C#12)
ログ
初版:2016.05.15 Visual Studio 2015 Professional (C# 6.0)
