creating custom objects

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

hi,

i have created many apps using the .net objects e.g. textbox, toolstrip. but
i have decided that i would like to go further with my c# studies and learn
how to write my own objects and create better apps but to start, i need to
know how to create my own objects.

can someone help me on my quest?

thanks in advance
 
i have created many apps using the .net objects e.g. textbox, toolstrip.
but
i have decided that i would like to go further with my c# studies and
learn
how to write my own objects and create better apps but to start, i need to
know how to create my own objects.

can someone help me on my quest?

Do you mean objects overall, or only controls like these in Windows Forms?
As you know, object is an instance of class. So you need to understand how
to
define classes (not objects) etc..
Read about constructors, methods, fields, operators, properties -> object
oriented programming.
Threre is a lot stuff in Internet, try google.

But if you mean objects as controls like WinForms, try examples in CodeGuru,
http://www.codeproject.com/
or google.
 
If I am following you correctly, you are asking how to create custom
controls based off of form objects. If that is the case then here is
how I usually start off:


using System;
using System.Windows.Forms;

namespace CustomControls
{

public class CustomButton : System.Windows.Forms.Button
{
public CustomButton() {}
// Add any other functionality you want in here.
}
}

The only "problem" doing it this way is that you cannot use the visual
design view to make changes, it is all code based. When you compile and
add it to a form it will appear correctly.

If you want to be able to view your control in designer mode:

namespace CustomControls
{

public class CustomButton : System.Windows.Forms.UserControl
{
private System.Windows.Forms.Button button1;
public CustomButton()
{
button1 = new Button();
}
// Add any other functionality you want in here.
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top