将数据从用户控件传递到Windows窗体 [英] Pass Data from User Control To Windows Form

查看:64
本文介绍了将数据从用户控件传递到Windows窗体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hai Sir,



我试图将数据从用户控件传递到Windows应用程序中的父窗体...传递数据来自windows窗体到用户控件工作正常......但用户控件表单不起作用

这里提供一些与我的任务相关的代码:



表单到用户控件:

i在用户控件中创建的属性,如

Hai Sir,

I am trying to pass data from user control to parent Form in windows application...passing data from windows form to user control is working fine...but user control to form is not working
here am providing some code related my task :

form to user control :
i created property in user control like

Private ChkSign As Boolean = False
Public Property CheckPhoto() As Boolean
       Get
           Return ChkPhoto
       End Get
       Set(ByVal value As Boolean)
           ChkPhoto = value
       End Set
   End Property





我从windows窗体传递布尔值...如果值为true我正在处理代码功能

在windows上形成它对我来说很好..但是点击按钮我将用户控件文本框文本值的值传递给主窗体..当我设置此窗体是一个启动页面时,它正在工作..但是当我从这个窗体来到这个窗体时,它不起作用另一种形式......请为此提供一些解决方案..



I am passing boolean value from windows form...if value is true am processing code functionality
on windows form its fine for me..but ofter click on button am passing value of user control text box text value to main form..it is working when i set this form is a start up page..but
it is not working when i come to this form from another form ...please give some solution for this..

推荐答案

您不应该尝试传递数据 - 表单应该询问它对数据的控制在您的示例中属性,但控件应该告诉通过活动获得数据的表格。



看看这个:在两种形式之间传递信息,第2部分:儿童到父母 [ ^ ] - 它在C#中,但想法完全一样。
You shouldn't try to pass data up - the form should ask it's controls for the data via properties as in your example, but the control should "tell" the form that data is available via an event.

Have a look at this: Transferring information between two forms, Part 2: Child to Parent[^] - it's in C# but the idea is exactly the same.


检查这些:

父Windows窗体和子用户控件传递数据 [ ^ ]

传递变量从子到父,像函数VB.N ET [ ^ ]
Check these:
Parent Windows Form and Child UserControl Passing Data[^]
Pass variable From child to parent, Like a Function VB.NET[^]


这篇关于将数据从用户控件传递到Windows窗体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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