gpt4 book ai didi

c# - 获取被点击按钮的文本值

转载 作者:太空狗 更新时间:2023-10-29 22:03:31 30 4
gpt4 key购买 nike

我正在尝试从被点击的按钮中获取文本值。在我看来,它看起来像这样:

private void button2_Click(object sender, EventArgs e)
{
string s = thisbutton.text
}

最佳答案

触发事件的对象是sender,所以:

private void button2_Click(object sender, EventArgs e)
{
string s = (sender as Button).Text;
}

关于c# - 获取被点击按钮的文本值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33299682/

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