用户控件中文本框中的文本

时间:2014-11-19 09:00:28

标签: winforms c#-4.0

我有一个组合框,用户可以从不同的项目中选择一个,

基于所选项目我正在显示带有各种标签和文本字段的UserControl。

如何从用户控件中的文本字段中获取值?

1 个答案:

答案 0 :(得分:0)

稍微尝试和错误之后,我的解决方案是在用户控件中创建一个getter,然后通过UserControls对象访问它。

     public string Text
     {
     get { return sampletextbox.Text; }

     }

     SampleControl sample = new SampleControl();

     string samplestring = sample.Text;