TextBox, DateTimePicker and OO

G

Guest

Hi,

I'm still somewhat new to OO. I am creating a class for a TextBox because I
need some specific things for it to do. That is, I'm inheriting a TextBox
and putting in some properties, etc. that I need for it. Now I find I need
to do something similar with a DateTimePicker. Many of the things I have to
add are the same. It seems to me that there's probably an OO way to handle
this so that I don't have to re-type all of the stuff I need in both new
classes. Unfortunately I have no clue how to do this. Can anyone help or
recommend something on-line to read?

Art
 
G

Guest

Jan. 13, 2005

You could create a class with common properties and then, on the Date
and Textbox controls, you could create a public property that returns this
class. Something like:

Public Class CommonProps
public property Name() as string
.... return Value
end property
public property Age() as string
.... return Value
end property
End Class

Public Class MyTxt
inherits textbox

private props as new commonprops

public property Common() as CommonProps
.... return props
end property

end class
'Then do the same with DateTimePicker

Then both of the controls will have a instance of the
CommonProps class that will contain the common additions that will be
publicly available. I hope this makes sense and that it helps! Have a great
day!


Joseph MCAD
 
G

Guest

Joseph,

Thanks! I don't think the idea of returning common properties will help my
specific situation. However, using that model I do think that adding a
separate class that both object can use will probably do the trick.

Thanks,

Art
 

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