471,309 Members | 1,089 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,309 software developers and data experts.

Form Property

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
Dec 15 '05 #1
3 1067
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

Dec 15 '05 #2
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.

"Steven Nagy" <le*********@hotmail.com> wrote in message
news:11*********************@f14g2000cwb.googlegro ups.com...
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

Dec 15 '05 #3
No problems!

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

Dec 15 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

10 posts views Thread by Gregory A Greenman | last post: by
4 posts views Thread by Stuart Perryman | last post: by
11 posts views Thread by Brian D | last post: by
3 posts views Thread by ApexData | last post: by
6 posts views Thread by Greg Strong | last post: by
9 posts views Thread by dhtml | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.