Custom Form Class / Adding Generic Functionality?
Hi All,
I am a developer who has been primarily developing financial software with Microsoft Visual FoxPro 9, I am just talking my initial steps into C# Windows Forms Development and seem to be getting on quite well, however there are just a few things still confusing me.
I am used to developing software professionally using a company 'Framework' that removes the need for many of the tasks that I am finding 'time consuming' within C# and Visual Studio.
For example, I would like the ability to create a 'Customised Form Class', this class would be the base class for all forms that are included within my application, I could then write all of the generic methods and properties that each form should include, im just talking methods that enable / disable each control on a page and properties that set the 'Enabled' / 'Disabled' state of the form (Assignable from an MDIParent?)
Is this possible? Im used to using FoxPro that enables me to base a new form on a customised 'Form' class.
I have read that C# will allow you to inherit only one class in a heiarchy, if this is the case, how would you add generic functionality to each form? Your help would be hugely appreciated.
Thanks
Nilanka DharmadasaPosted Oct 26, 2009, 11:34 PM
Hi friend,
If my answer helped you, please accept my answer. Coz it helps me. :)
Thanks..
Ben Paul MBCSPosted Oct 26, 2009, 10:49 AM
Many Thanks,
That is exactly what I was looking for, I have now created a base class customised form and im using an inherited form item when adding to my project, this has cleared up alot of what I was looking for.
Many Thanks
Nilanka DharmadasaPosted Oct 26, 2009, 12:47 AM
Yes . you can inherit only from a single class. But if you want multiple inheritance, then you can go for interfaces.
But for your case I guess, you need only one base class. You can write all the basic properties and methoda in the base class and all the other forms can be inherited from this base class.
public class BaseForm : Form
{
//Generic Properties
//Generic Methods
}
Then you can inherit toher forms from this class.
public class MyCustomizedForm : BaseForm
{
//Specific Properties
//Specific Methods
}
If this answer helps you please accept my answer.
If you need help let me know.