Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/csharp-4.0/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Winforms 用户控件中文本框中的文本_Winforms_C# 4.0 - Fatal编程技术网

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

Winforms 用户控件中文本框中的文本,winforms,c#-4.0,Winforms,C# 4.0,我有一个组合框,用户可以从不同的项目中选择一个 基于所选项目,我显示了一个带有各种标签和文本字段的UserControl 如何从用户控件的Textfield中获取值?经过一番尝试和错误后,我的解决方案是在用户控件中创建一个getter,然后通过UserControls对象访问它 public string Text { get { return sampletextbox.Text; } } 可以在用户控件中创建公共属性以公开texfield值。你可以

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

基于所选项目,我显示了一个带有各种标签和文本字段的UserControl


如何从用户控件的Textfield中获取值?

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

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

     }

可以在用户控件中创建公共属性以公开texfield值。你可以在这里分享一些你的代码。发布了一些指针和@coderhawk答案;我在你发表评论的那一刻就明白了。非常感谢。
     SampleControl sample = new SampleControl();
     string samplestring = sample.Text;