Form Property

B

Brett Wickard

How do you add a property to a form that will show up in the properties
window in the IDE? I can add the property to the form, but haven't been
able to see it in the properties window. I'm using the VS2005 if it makes
any difference... TIA
 
S

Steven Nagy

Making designable controls is a bit more advanced than that. But for
something simple, try this:

Create a BASEFORM class which is just a standard windows form. Add your
public property to it.
Then add a second class to your project that inherits from your
BASEFORM class, instead of System.Windows.Forms.Form

Now you will see your new form has the property you created in your
base class.

When you say Property, make sure it really is a PROPERTY, not just a
public variable.
Ie.
private string _testProperty = "";
public string TestProperty {
get {
return _testProperty;
}
set {
_testProperty = value;
}
}

Hope this gives you a good starting point.
I used the help walktroughts in MSDN to learn more about creating
custom controls.
You might like these too.

Steven Nagy
 
B

Brett Wickard

Thanks a lot for the reply --- you hit the nail on the head! I'm psyched
for c#, but I'm finding the learning curve fun/challenging at the same time.
 
S

Steven Nagy

No problems!

Slowly you'll learn to unlock the power and come to realise that OOP is
very easy in C#
 

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

Top