如何在WindowsApplication中的用户控件中清除文本框 [英] How to clear a TextBox in a User Control in WindowsApplication

查看:71
本文介绍了如何在WindowsApplication中的用户控件中清除文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我正在使用UserControl搜索(如Google)的目的.
在此,我使用TextBox和Listview,具体取决于TextBox
值我在列表视图中搜索项目.

问题:
根据UserControl文本框的值,我将相关数据保存到数据库中.
保存记录后.我需要清除TextBox中的文本.

Hi All,

I am using UserControl for searching(like google) purpouse.
In this i am using TextBox and Listview, Depending on TextBox
Value i am searching items in the listview.

Problem:
Depending on UserControl textbox value I am saving related data into database.
Once records are saved.I need to clear text in the TextBox .

推荐答案

尝试成功执行保存数据命令后运行给定代码.
Try to run given code after successful execution of saving data command.
foreach(TextBox textbox in this.Controls.OfType<TextBox>())
{
   textbox.Text = string.Empty;
}


在用于设置文本框值的User控件中实现一个属性.
然后,使用它清除主应用程序中的值.
Implement a property in the User control that sets the text box value.
Then, use it to clear the value in the main app.


保存记录后,您可以清空文本框
After save the record you can empty your text box
TextBox1.Text="";


这篇关于如何在WindowsApplication中的用户控件中清除文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆