Hi All,
I wanted to created a windows form with functions that are reusable. For example, creating a function to connect to the SQL server and validate user's name and password or insert record to SQL Server just by calling the AddRecord function.
TIA

How to create a base class windows Form?
DVdR
You would create a new windows form yourself, let's say "Form1". That form will automatically inherit from the Form class. Add your methods to Form1 for connecting to the database, at a minimum the methods need to be classified as protected so that descendent forms will be able to access the methods. Leave the rest of the form as is.
Now every form that you create in your application from this point forward use the manner that I described earlier to inherit from Form1. You will then be able to call the methods from Form1 within all of your new forms as if the methods were directly declared in those forms.
Does that help
toc996
public class BaseForm : Form
{
public void MyMethod()
{
MessageBox.Show("Hello");
}
}
public class DerivedForm : BaseForm
{
public DerivedForm()
{
MyMethod();
}
}
EA512
I am new at C# and I know "Inherited Form" is a nice feature. But how do I find out if the inherited form already have functions that I need If "Not", how do I include the new functions to the inherited form or build my own
TIA.
JBJBJB
Using that method you could have all of the forms in your project descend from a common form in which you can put some of your methods. Whether that is the proper design for your situation though is up to you.