根据文本框c#窗体的值动态更改标签的值

时间:2021-04-09 00:03:32

根据文本框c#窗体的值动态更改标签的值

Here I want to insert some value in present payment and the value of due will be changed according to the value dynamically.

在这里,我想在当前付款中插入一些值,并且将根据值动态更改到期的值。

2 个解决方案

#1


2  

you can add an event handler to the textbox TextChanged event and then use this to update label text

您可以向文本框TextChanged事件添加事件处理程序,然后使用它来更新标签文本

textBox1.TextChanged += textBox1_TextChanged;

and then in textBox1_TextChanged

然后在textBox1_TextChanged中

void textBox1_TextChanged(object sender, EventArgs e)
{
    label1.Text = textBox1.Text + " In label";
}

#2


2  

Add an event to the TextBox's TextChanged even that updates the Label's Text

将事件添加到TextBox的TextChanged,甚至更新Label的Text

//assuming myTextBox and myLabel
myTextBox.TextChanged += myTextBox_TextChanged;

void myTextBox_TextChanged(object sender, TextChangedEventArgs e)
    {
        myLabel.Content = myTextBox.Text;
    }

#1


2  

you can add an event handler to the textbox TextChanged event and then use this to update label text

您可以向文本框TextChanged事件添加事件处理程序,然后使用它来更新标签文本

textBox1.TextChanged += textBox1_TextChanged;

and then in textBox1_TextChanged

然后在textBox1_TextChanged中

void textBox1_TextChanged(object sender, EventArgs e)
{
    label1.Text = textBox1.Text + " In label";
}

#2


2  

Add an event to the TextBox's TextChanged even that updates the Label's Text

将事件添加到TextBox的TextChanged,甚至更新Label的Text

//assuming myTextBox and myLabel
myTextBox.TextChanged += myTextBox_TextChanged;

void myTextBox_TextChanged(object sender, TextChangedEventArgs e)
    {
        myLabel.Content = myTextBox.Text;
    }