Adding my own properties to a control

  • Thread starter Thread starter Dino M. Buljubasic
  • Start date Start date
D

Dino M. Buljubasic

Is it possible to add my own property to a control?

For example, since MainMenu control does not have Background property, can I
add my own and use it to set the color.

Thank you,
Dino
 
Hi Dino,

You can't retro-propertyise (luv that word) a Control but you can inherit
from it and add properties to your version. Having done that there is a choice
of implementation.

You can replace the type of the one created in Design mode with your
own (ie in the Designer-generated section of code). This runs the risk of
being wiped out if you play with the Form's design. It has the worse
disadvantage of being 'hidden' from subsequent programmers in an area that
they rightfully expect to have nothing unorthodox. You would have to document
it very clearly.

The other way is to take the Designer generated code out into your own
methods and then replace with your type. This makes it clearer and safer from
loss, but means that you can't use the Designer to make any further changes.

Regards,
Fergus

ps 1. Have you got anywhere with integrating the additions? and
ps 2. Cor would like to see the Calendar but that requires your permission.
How's about it?
 
Thanks Fergus,

I am still developing the rest of the forms, they look quite different now
:).

Still having a problem with resizing. From some reason, when calendar gets
maximized, then clicked again the same button to 'Restore it Down' (that is
the button btw minimize and close when form is maximized), it does not work
properly, the form gets restored then maximized again and placed in the
center or screen so that the right and bottom go well off the screen.

Setting StartPosition to Manual and WindowsState property to Maximized
solves the problem partially though. Haven't had chance to take closer look
at this yet though, so don't know the real reason yet.

The rest of the forms look quite good, weekly/daily calendar is done pretty
much but there is still lots of things to be added. I am wondering if you
would have time to take a look on my daily calendar. It is pretty much
done; however, there is a quite annoying thing happening and I think it is
simple to solve it, I just don't know how, but maybe I am wrong. When I
open the Dailiy Calendar form and then click on a field to enter a daily
event, say at 2:00, the panel holding the user controls I have build
scrolls to the right so the hours get invisible.

I was thinking maybe there is a way to reset the scroll bar to positin 0 so
this does not happen but wasn't successfull with that. Anyways, just in
case you have some time. .... and thanks in advance. I'll send you
calendar some time today.

Re. Cor, please go ahead. Calendar is still just a GUI so I don't have
problems with sharing. At a later stage, my boss may prefer some type of IP
agreement ; as I am building for him, but all involved here appreciate your
help.

Regards,
Dino
 
Hi Dino,

Progress sounds good. I'm quite happy to take a look at the resizing and
scroll issues. (I saw that post, but there wasn't enough to go on). So it's
good that you are sending it.

One thing, though. If the changes that I've already given you aren't
already in the mix, and I make new changes, that will leave three versions
requiring integration. I'd prefer that the first two were merged and we were
working on stable common ground.

Thanks for the permission to share it with Cor. I'll do that with the
latest version.

How would your boss like to hire me as a part-time code reviewer/trainer?!

Regards,
Fergus
 
Back
Top