My app consists of a main form and a tab control with 2 tabs, one tab is a datagird that will display all companies.
The other tab will be a detail view which I will add custom controls to depending on the type of object loaded to the data grid.
When the user click a data row, I will get a datarow send that to a companyFactory and that will return a company that has populated itself with data from the row.
It will then create an event handler that will be used in the main form and pass the company.
In the main form I will pass the Icompany to the UserControlFactory which will get the appropriate user control and populate that controls txtboxes and comboxes with the company data (company name, address, contact) and then add this userControl to the tabpage tab1
I am wondering if this is a good design and if so what patter to use for the mapping of the datarow to the Icomapny and also what pattern to use for the populating the user control from the Icomapny data.
I have a Icompany object there are 3 kinds of companys assuming, CedingCompany, and directCompany. I will have 3 user controlls one for each type of company. I dont know anything about directCompany or AssumingCompany, just know that they will exist in the future.
for all companys they will display in a data grid and when the user wants to edit one they click the grid row and i will then get the datagridviewrow and....
this is what i was thinking, in the gridView usercontrol for the row click protected virtual void OnClickRow(DataRow row) {
ICompany company = CompanyFactory.GetCompany(row["CompanyType"],row);
EventHandler<ClickRowEventArgs> handler = this.ClickRow; if (handler != null) handler(this, new ClickRowEventArgs(company)); }
in the main form: private void frmMain_ClickRow(object sender, ucDataGrid.ClickRowEventArgs e) { UserControl control = ControlFactory.GetUserControl(company); tabControl.Controls.Add(Control); }