폼에는 4 개의 버튼이 있으며, 사용자는 버튼을 위, 아래, 왼쪽 및 오른쪽으로 클릭하여 단어를 입력해야합니다.버튼을 통한 텍스트 입력
사용자는 위 아래로 이동하여 자신의 문자, 숫자 또는 기호를 선택할 수 있습니다.
왼쪽과 오른쪽은 단어 안에서 앞뒤로 갈 것입니다. 그가 현재 편지를 확인하고 싶을 때를 대비해서 실수를하고 포워드했다.
이
이 내가 지금 무엇을 가지고private int i;
public Form1()
{
InitializeComponent();
tbOutput.Text = word;
}
private void btnUp_Click(object sender, EventArgs e)
{
//We don't want the i to go above the array
if (i <= 39)
{
i = i + 1;
}
tbOutput.Text = word + Convert.ToString(wordsAndLetters[i]);
}
private void btnDown_Click(object sender, EventArgs e)
{
//We don't want the i to go below the array
if (i > 0)
{
i = i - 1;
}
tbOutput.Text = word + Convert.ToString(wordsAndLetters[i]);
}
private void btnRight_Click(object sender, EventArgs e)
{
tbOutput.Text = word;
sb.Append(wordsAndLetters[i]);
word = sb.ToString();
i = 0;
tbOutput.Clear();
tbOutput.Text = word;
}
private void btnLeft_Click(object sender, EventArgs e)
{
int lengthword = sb.Length;
sb.Remove(lengthword -1, 1);
word = sb.ToString();
tbOutput.Clear();
tbOutput.Text = word;
}
}
등, 우리는 버튼에게 문자 사이에 갈 수있는 옵션을 제공 할 필요가
private string word;
private StringBuilder sb = new StringBuilder();
private char[] wordsAndLetters = { ' ', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', ',', '.', '!', '?' };
이제 변수와 그것을 작동하지만 그것은 완벽하지 않습니다. 현재 프로그램을 더 잘 만들 수있는 방법이 있습니까?
'StringBuilder'와'.Append (char)'를보세요. –