473,386 Members | 1,830 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

TextBox, DateTimePicker and OO

Art
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
Nov 21 '05 #1
2 1260

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
"Art" wrote:
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

Nov 21 '05 #2
Art
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

"Joseph MCAD" wrote:

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
"Art" wrote:
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

Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Simon Whale | last post by:
Hi, is there a way within vb,net to specify the way that information is entered into a textbox? for example a field that requires data to be inputted as DD/MM/YYYY i know this was possible...
5
by: christian ternek | last post by:
Hello ! I want to make a custom textbox and inherit a custom control from textbox. Now i want to change the looking of the textbox with the following code: protected override void...
0
by: Sumit | last post by:
Hi all, I have a datetimepicker on my windows form. When the user selects it i check whether the date entered is a Sunday or not & if its not a sunday i want that the control remains on the...
3
by: Darin | last post by:
Is there a way to, at runtime, change a textbox to be a datetimepicker? I have a form that I allow the user to specify what field types the input boxes are. They can be regular text, integer,...
1
by: Rich | last post by:
Hello, I have some datefields in a dataset (ds1). I bind some textbox controls on a windows form to these date fields in ds1, but I only want to see 01/01/2004 instead of 1/1/2004 8:00:00 AM. ...
7
by: Clamara | last post by:
When adding a new record from my form, I pre-set my DateTimePicker's value to System.DateTime.Today Since the "Today" value is used most of the time, the user doesn't need to select a date from...
3
by: Charlie | last post by:
In the top portion of the DateTimePicker, where the value of the date is displayed, how can I detect whether the month or day or year is currently focused, or, if ShowCheckBox = True, whether the...
3
by: Simon Tamman | last post by:
I've come across an interesting bug. I have workarounds but i'd like to know the root of the problem. I've stripped it down into a short file and hope someone might have an idea about what's going...
4
by: fts2012 | last post by:
' if the textbox is empty show an error message 1001 Private Sub TextBox1_Validating(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles TextBox1.Validating...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.