我想將文本插入標籤,但文本必須慢慢插入/按字母/字母/字母, 有點像在舊的MUD遊戲中。獲取標籤以緩慢插入文本
到目前爲止,我已經試着這樣做:
private void StoryBox_Click(object sender, EventArgs e)
{
string text = StoryBox.Text;
var index = 0;
var timer = new System.Timers.Timer(2000);
timer.Elapsed += delegate
{
if (index < text.Length)
{
index++;
StoryBox.Text = "This should come out pretty slowly ";
}
else
{
timer.Enabled = false;
timer.Dispose();
}
};
timer.Enabled = true;
}
這是我從網站上收集的,但我不是特別明白爲什麼這是行不通的。
正如你可以看到它在StoryBox_Click
下。
有沒有辦法讓這個自動化?所以當程序打開時,它會計算幾秒鐘,然後開始寫出文本。
你是什麼意思?你的意思是寫信嗎? – Youssef13
@ Youssef13是的。 –