473,662 Members | 2,588 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1284

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
1433
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 with VB6 as you could use a masked textbox. can somebody point me in the right direction?
5
9587
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 OnPaint(PaintEventArgs e) {
0
2171
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 DateTimePicker & the DateTimePicker is displayed in its expaned form (i.e displaying the calendar). If i do a datetimepicker.focus(), then the focus goes to the datetimepicker but the user who is using it might ignore the focus as
3
4880
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, money, date, or date&time. So, I have the textbox and when I see that this field is a date, I want to change the textbox to a datetimepicker. Can that be done at runtime? TIA
1
9401
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. In a DateTimePicker control I can set a custom format("MM/dd/yyyy"). So when I iterate through ds1 with currency manager (cma) I see the correct date format in a DateTimePicker control. Is it possible to set a custom date format like that for...
7
6199
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 the DateTimePicker, since the default is shown. My problem is, if the user does not choose a value from the DateTimePicker (because using the default is good enough), then during database update, the date value is not saved to the database; while if...
3
6372
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 checkbox is focused?
3
7505
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 on. It's a simple program that loads a control onto a form and binds "Foo" against a combobox ("SelectedItem") for it's "Bar" property and a datetimepicker ("Value") for it's "DateTime" property. The DateTimePicker.Visible value is set to...
4
2669
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 TextBox1.BackColor = Color.White If TextBox1.Text.Length = 0 Then TextBox1.Select() TextBox1.BackColor = Color.Yellow MsgBox("1001") e.Cancel = True
0
8432
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8344
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8857
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8764
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8546
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7367
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6186
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4347
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1993
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.