473,396 Members | 1,866 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,396 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 1668
"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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.