将控件的内容传递给另一个表单 [英] pass contents of a control to another form

查看:58
本文介绍了将控件的内容传递给另一个表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将数据从当前表单传递到第二个表单以保存第二次输入数据。以下是我要做的事情:

I am trying to pass data from current form to a second form to save entering the data a second time. Here is what I am trying to do:

Inventory_Info_Form inventory_Info_Form = new Inventory_Info_Form();
inventory_Info_Form.part_NumberComboBox.Text= part_NumberComboBox.Text;
inventory_Info_Form.part_DescriptionTextBox.Text = part_DescriptionTextBox.Text;
while (inventory_Info_Form.ShowDialog() != DialogResult.OK)
{
}



带下划线的控件给出了以下错误:

inventory_Info_Form.part_NumberComboBox由于其保护级别而无法访问,而下一行的粗略级别相同。



我在另一个类中有相同类型的代码行但是无法弄清楚它在其他类中的工作原理而不是在这个类中。



任何想法?谢谢


the underlined controls are giving me the following error:
inventory_Info_Form.part_NumberComboBox is inaccessible due to its protection level and the same of coarse for the next line.

I have this same type line of code in another class but can't figure out why it works in the other class and not in this one.

any ideas? Thanks

推荐答案



检查这个

这里 [ ^ ]

Best问候

M.Mitwalli
Hi ,
Check this
Here[^]
Best Regards
M.Mitwalli


Use parametrized constructor to send data from one from to another .You can use code as follows (Sending form)







Inventory_Info_Form inventory_Info_Form = new Inventory_Info_Form(part_NumberComboBox.Text,part_DescriptionTextBox.Text);
while (inventory_Info_Form.ShowDialog() != DialogResult.OK)
{
}







So you need to define a parametrized constructor for the form named  Inventory_Info_Form . To do you know you can define a parametrized like bellow(Receiving form) 







public Inventory_Info_Form(string combotext,string descriptionText)
{
inventory_Info_Form.part_NumberComboBox.Text= combotext;
inventory_Info_Form.part_DescriptionTextBox.Text = descriptionText;
}







Hope it works! Happy Coding :)


这篇关于将控件的内容传递给另一个表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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