gpt4 book ai didi

c# - 如何在同一个句子中添加(附加)一个单词,每个单词使用一个按钮(单击)

转载 作者:行者123 更新时间:2023-12-02 05:14:42 25 4
gpt4 key购买 nike

我非常感谢任何帮助。我有 20 多个按钮,每个按钮都有一个词、一个空格或句号。每次我点击一个按钮,之前存在的单词就会被删除并被新单词替换。在单击“清除”按钮之前,我需要每个单词和/或空格都保留在原位。

也许这个问题之前已经在不同的搜索词下被问过/回答过?我倾向于认为我需要识别一个字符串变量,但不知道如何开始。

==============

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
public partial class frmSentenceBuilder : Form
{
public frmSentenceBuilder()
{
InitializeComponent();
}

private void frmSentenceBuilder_Load(object sender, EventArgs e)
{

}

private void btnA_Click(object sender, EventArgs e)
{
lblSentenceText.Text = btnA.Text;
}

private void btn_a_Click(object sender, EventArgs e)
{
lblSentenceText.Text = btn_a.Text;
}

private void btnAn_Click(object sender, EventArgs e)
{
lblSentenceText.Text = btnAn.Text;
}

private void btn_an_Click(object sender, EventArgs e)
{
lblSentenceText.Text = btn_an.Text;
}

private void btnThe_Click(object sender, EventArgs e)
{
lblSentenceText.Text = btnThe.Text;
}

private void btn_the_Click(object sender, EventArgs e)
{
lblSentenceText.Text = btn_the.Text;
}

private void btnman_Click(object sender, EventArgs e)
{
lblSentenceText.Text = btnman.Text;
}

private void btnwoman_Click(object sender, EventArgs e)
{
lblSentenceText.Text = btnwoman.Text;
}

private void btndog_Click(object sender, EventArgs e)
{
lblSentenceText.Text = btndog.Text;
}

private void btncat_Click(object sender, EventArgs e)
{
lblSentenceText.Text = btncat.Text;
}

private void btncar_Click(object sender, EventArgs e)
{
lblSentenceText.Text = btncar.Text;
}

private void btnbicycle_Click(object sender, EventArgs e)
{
lblSentenceText.Text = btnbicycle.Text;
}

private void btnbeautiful_Click(object sender, EventArgs e)
{
lblSentenceText.Text = btnbeautiful.Text;
}

private void btnbig_Click(object sender, EventArgs e)
{
lblSentenceText.Text = btnbig.Text;
}

private void btnsmall_Click(object sender, EventArgs e)
{
lblSentenceText.Text = btnsmall.Text;
}

private void btnstrange_Click(object sender, EventArgs e)
{
lblSentenceText.Text = btnstrange.Text;
}

private void btnlookedat_Click(object sender, EventArgs e)
{
lblSentenceText.Text = btnlookedat.Text;
}

private void btnrode_Click(object sender, EventArgs e)
{
lblSentenceText.Text = btnrode.Text;
}

private void btnspoketo_Click(object sender, EventArgs e)
{
lblSentenceText.Text = btnspoketo.Text;
}

private void btnlaughedat_Click(object sender, EventArgs e)
{
lblSentenceText.Text = btnlaughedat.Text;
}

private void btndrove_Click(object sender, EventArgs e)
{
lblSentenceText.Text = btndrove.Text;
}

private void btnSpace_Click(object sender, EventArgs e)
{
lblSentenceText.Text = " ";
}

private void btnperiod_Click(object sender, EventArgs e)
{
lblSentenceText.Text = btnperiod.Text;
}

private void btnexclam_Click(object sender, EventArgs e)
{
lblSentenceText.Text = btnexclam.Text;
}

private void btnClear_Click(object sender, EventArgs e)
{
lblSentenceText.Text = "";
}

private void btnExit_Click(object sender, EventArgs e)
{
this.Close();
}
}
}

最佳答案

使用 lb1SentenceText.Text+=whatever.Text;

+= 等同于 lbSentence.Text = lblSentenceText.Text + whatever.Text

基本上,它将右侧的 string 附加或连接到左侧的 string。希望它有意义?

所以:

string rhs="Hello " ;
string lhs = "World";
string rhs = rhs + lhs;//Hello World

关于c# - 如何在同一个句子中添加(附加)一个单词,每个单词使用一个按钮(单击),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14841843/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com