Click here to Skip to main content
15,899,754 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
C#


Below this code I'm trying to figure out how these forms can freely accessed their both objects. In these code, 

 - ITEMCount can access the objects of SIMSProduct
 - On the other side although SIMSProduct can see the objects of ITEMCount
(There is no argument given that corresponds to the required formal parameter 'view' of 'SIMSProduct.SIMSProduct(ITEMCount)')


What I have tried:

//Form that use SIMSPRODUCT controls
        public partial class ITEMCount : Form
        {
        SIMSProduct  _view;
        public  ITEMCount(SIMSProduct view)
        {
            InitializeComponent();
            _view = view;
            DisplayQuantity();
        }
        }
        // Form controls that been accessed by ITEMCOUNT
        public partial class SIMSProduct : UserControl
        {
        ITEMCount _view;
        public SIMSProduct(ITEMCount view)
        {
            InitializeComponent();
            _view = view;
        }
   
        }

        //Code for calling the ITEMCount form
            new ITEMCount(this).ShowDialog(); // Belongs to SIMSProduct form

        //Code for calling the SIMSProduct form
            var obj = new SIMSProduct(); // this where error point out
            obj.Dock = DockStyle.Fill;
            panel3.Controls.Clear();
            panel3.Controls.Add(obj); 
Posted
Updated 8-Sep-18 2:34am

1 solution

You forgot the required parameter to the constructor. You declare the constructor:
C#
public SIMSProduct(ITEMCount view)

But then you fail to pass a view parameter in your call, which is:
C#
var obj = new SIMSProduct();
 
Share this answer
 
Comments
xdiet 8-Sep-18 8:44am    
So what's the solution ?
Richard MacCutchan 8-Sep-18 9:22am    
Pass an ITEMCount object to the constructor, as you have defined it.
xdiet 8-Sep-18 10:04am    
where is that sir ?
Richard MacCutchan 8-Sep-18 10:17am    
Why are you asking me? This is your code so you need to follow the design that you have created. Your SIMSProduct constructor takes an ITEMCount object as its single parameter. Your code has a parameterless constructor which does not exist.

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