private void button1_Click(object sender, EventArgs e)
{
string c;
string a;
int b = 0;
foreach (char m in textBox1.Text)
{
b++;
a = m.ToString();
if (a=="a"&&b==1)
{
textBox2.Text = "Error";
}
c = m.ToString();
textBox2.Text = c;
}
}
你好 我想在textbox1中输入内容,并在textbox2中查看textbox1的字符 例如: 在textbox1中键入“ Hello”,在textbox2中看到“ H e l l o”,但我在textbox2中看到了textbox1的最后一个字符“ o”
我该怎么办?
答案 0 :(得分:3)
您可以使用imread('project_folder/another_folder/.../chest.jpg')
并一次性完成:
Table table = new Table();
table.setFillParent(true);
table.setDebug(true);
stage.addActor(table);
Skin skin = new Skin(Gdx.files.internal("skin/glassy-ui.json"));
final TextButton atis = new TextButton("", skin);
table.row().pad(10, 0, 10, 0);//UÇAK1 BOTUNUN YERİ
table.add(atis).uniformX();
atis.addListener( new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
stage= new Stage();
Gdx.input.setInputProcessor(stage);
batch.begin();
batch.draw( bulletTexture, birdX+testBullet.bulletLocation.x, birdY );
batch.end();
};
});
答案 1 :(得分:2)
textBox2.Text = c;
这将覆盖textBox2。试试
textBox2.Text += c;
编辑:当你还是一个学生的时候,我要简化一下。
对于空格,将上一行替换为:
if(b==1)//that means this is first char of your textbox. And we wont add spaces.
{
textBox2.Text+=c;
}
else//that means its not first, and we need to add spaces.
{
textBox2.Text+= ' '+c;
}
但是您需要注意一些事项:
c
是多余的。尝试将所有c
替换为a
,包括解决方案答案 2 :(得分:1)
您可以使用TextChanged事件处理自动完成此操作:
textBox1.TextChanged += TextBox1_TextChanged; //set up this first
void TextBox1_TextChanged(object sender, EventArgs e)
{
var text1WithSpaces = string.Join(" ", textBox1.Text.ToCharArray());
textBox2.Text = text1WithSpaces;
}