将LabelName从一种形式传递到另一种形式的文本框..! [英] Pass LabelName from One form to another forms Text Box..!
问题描述
嗨...!
我有两个Windows窗体,例如Form_A和Form_B!现在在Form_A上有十个标签
当用户登录时,他的名字将显示在他单击的位置或标签上!它工作..!但是现在我想要的是,当用户单击其登录名显示的标签时,应该显示Form_B,而当应该显示Form_B时,将出现一个文本框..!我要我的登录名的地方..!
那么它是如何工作的..!
在单击10个标签后不久,当我单击任何标签时,该标签名称将在加载时在Form_B文本框中显示!
Hi...!
i have two windows form like Form_A and Form_B! now on Form_A there are ten labels
when user get in Login his name will be display on the label where or on which labels he clicks! it working..! but now what i want when user clicks on the label where his Login name shows, Form_B should be display and when Form_B should be display there will be a text Box..! where i want my LogIn Name..!
so how it works..!
in shortly from 10 labels when i click any label thats label name should be display on Form_B Text Box when it will load!
regards!
推荐答案
在表格B上,创建一个属性:
Hi,
On form B, create a property :
public string fieldAValue
{
get { return tbAValue.Text; }
set { tbAValue.Text = value; }
}
在表格A上,填充属性:
On form A, populate the property :
using (Form_B frmB = new Form_B())
{
frmB.fieldAValue = lblFieldAValue.Text;
if (frmB.ShowDialog(this) == DialogResult.OK)
{
// Do stuff here
}
}
对您要传递的每个字段重复此操作.如果所有字段都是某类对象,则可以选择传递整个对象和/或使用DataBinding.
祝你好运,
爱德华
Repeat this for each field you want to pass. If all fields are in som kind of object, you can choose to pass the entire object and/or use DataBinding instead.
Good luck,
Eduard
本文将为您提供帮助...
使用委托以在两种形式之间传递数据 [
Hi,
This article will help you...
Using a delegate to pass data between two forms[^]
这篇关于将LabelName从一种形式传递到另一种形式的文本框..!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!