Click here to Skip to main content
15,949,686 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

I have been searching for an answer without any success. I dont even know how to call this programming design. Anyway, this is my question:

I have multiple Forms created, but some of the control object in the forms are the same. In addition to the same control objects, the each individual form has additional controls that are not common to the others. I wish to create a function that I can pass a form (which would be dynamically created) and be able to manage the control objects that are common between all forms.

This is a very crude example of what I wish to do. Lets say there are two classes with:
public class FormA
    dim txtBoxA as System.Windows.Forms.Textbox
    dim txtBoxB as System.Windows.Forms.Textbox
    dim cbxBoxA as System.Windows.Forms.Checkbox
end class

public class FormA
    dim txtBoxA as System.Windows.Forms.Textbox
    dim txtBoxB as System.Windows.Forms.Textbox
    dim cboLine as System.Windows.Forms.Combobox
end class


Then at the main class i could dynamically create and call

Public class Main
Sub Main
   select case OPTION
       case OPTION.formA
             generic = New FormA
       case OPTION.formB
             generic = New FormB
   end case

   MyControllingFunction(generic)

End Sub
Posted

1 solution

Your business layer should be responsible for common actions on text, and your UI layer should call it accordingly. You should create user controls for groups of controls and functionality that exist in common between two forms.
 
Share this answer
 
Comments
Arerbac 28-Aug-10 19:01pm    
But how would you do that in .NET do I create inheritance using abstract classes? or is it an interface common to all forms?

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