C# - 如何在消息框中显示textbox.text? [英] C# - how do I display textbox.text inside a messagebox?
本文介绍了C# - 如何在消息框中显示textbox.text?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试在MessageBox中显示textBox的文本。根本没有错误消息。 TextBox的内容根本没有出现在MessageBox中(代码中的第一个MessageBox)。你能看看它并告诉我出了什么问题吗?对此,我真的非常感激。谢谢!最好的祝福。 :)
我的尝试:
I am trying to display the text of a textBox inside a MessageBox. There are no error messages at all. The contents of the TextBox simply don't appear in the MessageBox (first MessageBox in the code). Can you please take a look at it and tell me what's wrong? I really appreciate it. Thank you! Best regards. :)
What I have tried:
private void bindingNavigatorDeleteItem_Click(object sender, EventArgs e)
{
if (MessageBox.Show("Tem certeza que deseja excluir o pagamento " + cod_caixaTextBox.Text, "Atenção", MessageBoxButtons.OKCancel) == System.Windows.Forms.DialogResult.OK)
{
this.caixaBindingSource.EndEdit();
this.tableAdapterManager.UpdateAll(this.bremingtonBackEndDataSet);
MessageBox.Show("Pagamento excluido com sucesso!", "Pronto ...", MessageBoxButtons.OK);
}
else
{
caixaBindingSource.CancelEdit();
this.caixaTableAdapter.Fill(this.bremingtonBackEndDataSet.caixa);
}
}
推荐答案
我发现问题是什么:TextBox内容的原因是什么MessageBox中没有显示的是因为当我单击BindingNavigatorDeleteItem时,它会删除记录而不进行确认,因此MessageBox无法显示TextBox.Text,因为它已被删除。现在我必须找到一种方法来在BindingNavigatorDeleteItem删除记录之前添加确认。有什么想法吗?
I found what the problems is: the reason why the contents of the TextBox are not displayed in the MessageBox is because when I click on the BindingNavigatorDeleteItem, it deletes the record without confirmation, thus the MessageBox can't display the TextBox.Text because it has been deleted. Now I have to find a way to add the confirmation BEFORE the BindingNavigatorDeleteItem deletes the record. Any ideas?
SUCCESS !!!我需要做的就是将绑定导航器的DeleteItem属性设置为NONE,这样我就可以手动处理事件了。
SUCCESS!!! All I needed to do was set the DeleteItem property of the binding navigator no NONE so I could handle the event manually.
这篇关于C# - 如何在消息框中显示textbox.text?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文