C# 開発

【C#】TextBox

2025.01.23 TextBox : 内容をクリアする (2)

private void button1_Click(object sender, EventArgs e)
{
   textBox1.Clear();
}

2025.01.23 TextBox : StringReader を使用して 1 行ずつ読み込む

private void Form1_Load(object sender, EventArgs e)
{
    textBox1.Text = "テスト1\r\nテスト2\r\nテスト3\r\nテスト4\r\nテスト5\r\n";
}

private void button1_Click(object sender, EventArgs e)
{
    using (var rs = new System.IO.StringReader(textBox1.Text))
    {
        while (rs.Peek() > -1)
        {
            string sWork = (rs.ReadLine() ?? "").Trim();
            listBox1.Items.Add(sWork);
        }
    }
}

-C# 開発