473,387 Members | 1,504 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,387 software developers and data experts.

Inheriting Methods

I have a text box class, in which I want this code to run each time the
textbox gets the focus:

this.Text = this.Text.Trim()

How do I wire this up?

I can wire it up at the form level, but then I have to put the code in each
text box in the Enter Event.

The textbox base class is currently and empty shell that looks like this:

class TextBoxBase: TextBox
{
}

Thanks,

Greg
--
Greg Gum
Nov 17 '05 #1
2 1667
"Greg" <Gr**@discussions.microsoft.com> wrote in message
news:23**********************************@microsof t.com...
I have a text box class, in which I want this code to run each time the
textbox gets the focus:

this.Text = this.Text.Trim()

How do I wire this up?

I can wire it up at the form level, but then I have to put the code in
each
text box in the Enter Event.

The textbox base class is currently and empty shell that looks like this:

class TextBoxBase: TextBox
{
}
I wouldn't use TextBoxBase, since there is already a class in the .NET
Framework called that.

class TrimTextBox: TextBox
{
protected override void OnEnter(EventArgs e) {
base.OnEnter(e);

Text = Text.Trim();
}
}

Thanks,

Greg
--
Greg Gum

Nov 17 '05 #2
"Greg" <Gr**@discussions.microsoft.com> wrote in message
news:23**********************************@microsof t.com...
I have a text box class, in which I want this code to run each time the
textbox gets the focus:

this.Text = this.Text.Trim()

How do I wire this up?

I can wire it up at the form level, but then I have to put the code in
each
text box in the Enter Event.

The textbox base class is currently and empty shell that looks like this:

class TextBoxBase: TextBox
{
}
I wouldn't use TextBoxBase, since there is already a class in the .NET
Framework called that.

class TrimTextBox: TextBox
{
protected override void OnEnter(EventArgs e) {
base.OnEnter(e);

Text = Text.Trim();
}
}

Thanks,

Greg
--
Greg Gum

Nov 17 '05 #3

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

Similar topics

15
by: JustSomeGuy | last post by:
this doesn't want to compile.... class image : public std::list<element> { element getElement(key k) const { image::iterator iter; for (iter=begin(); iter != end(); ++iter) { element...
1
by: john diss | last post by:
hello there everyone.. I have created a class called "ProcessLog" inheriting from XmlDocument and two classes ("UploadedItem", "ProcessError") inheriting from XmlElement. I then have two...
11
by: Noah Coad [MVP .NET/C#] | last post by:
How do you make a member of a class mandatory to override with a _new_ definition? For example, when inheriting from System.Collections.CollectionBase, you are required to implement certain...
10
by: Andrew McLellan | last post by:
I think I must be missing something about generics, perhaps just about the syntax. I'd like to derive a class MyList from System.Collections.Generic so that it can only contain instance of MyItem....
1
by: Matthew Roberts | last post by:
Howdy Everyone, I am having trouble understanding the process of creating a type-safe collection by inheriting from the CollectionBase class. I have done it plenty of times, but now that I sit...
2
by: Jim Heavey | last post by:
I amd playing around with inheritance a little in VB.Net If I create a new class which inherits from ListViewItem and I am only wanting to override the ToString Method. In this situation, If I...
6
by: MSDNAndi | last post by:
Hi, I have a baseclass (non-static) with some static and some non-static methods/fields/properties. In the baseclass in one of the static methods I need to do something like " somelogic...
24
by: toton | last post by:
Hi, I want to have a vector like class with some additional functionality (cosmetic one). So can I inherit a vector class to add the addition function like, CorresVector : public...
1
by: UptownYardy | last post by:
Hi excuse the mistake in the title. I'm having trouble on inheriting methods from a superclass in Java. Basically I've forgotten how to. I want to inherit 3 methods from the Artwork superclass to...
3
by: shaun roe | last post by:
Hello, I am working in a framework with certain restrictions; in particular I have a 'data' class with getter and setter methods, and a some 'filling' classes which know how to insert the data to...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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
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,...
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.