Click here to Skip to main content
15,886,110 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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:
C#
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)
{
}

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
Posted
Updated 8-Feb-15 17:34pm
v2

Hi ,
Check this
Here[^]
Best Regards
M.Mitwalli
 
Share this answer
 
Use parametrized constructor to send data from one from to another .You can use code as follows (Sending form)


C#
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) 


C#
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 :)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900