473,804 Members | 2,124 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Overriding Base Properties

This question concerns something I'm trying to do with the CF but it's really
a generic C# question.

With the Compact Framework, one can't add a radio button with a long label
because the labels don't wrap. So I've decided to create my own custom radio
button. With my version there will be a basic radio button with no text and
its size reduced to 12 x 12. Then beside this I will place a LinkLabel,
which will wrap, to give the appearance of a multi-line label.

Here's the basic code I've written so far:

public class RadioButtonEx : RadioButton
{
LinkLabel linkLabel = new LinkLabel();

public RadioButtonEx()
{
base.Width = 12;
base.Height = 12;
linkLabel.Click += new EventHandler(li nkLabel_Click);
}

private string text;
public override string Text
{
get
{
return text;
}
set
{
text = value;
linkLabel.Text = value;

if (this.Parent != null)
{
if (! this.Parent.Con trols.Contains( linkLabel))
{
this.Parent.Con trols.Add(linkL abel);
linkLabel.Locat ion = new Point(this.Righ t + 6, this.Top);
}
}
}
}

private string width;
public override int Width
{
get
{
return width;
}
set
{
linkLabel.Width = value - 18;
}
}

private string height;
public override int Height
{
get
{
return height;
}
set
{
linkLabel.Heigh t = value;
}
}

private void linkLabel_Click (object sender, EventArgs e)
{
this.Checked = true; // If the label is clicked then check the radio
button
}
}
But I'm getting this sort of error about the gets and sets of the Width &
Height:

Cannot override inherited member 'System.Windows .Forms.Control. Width.set'
because it is not marked virtual, abstract, or override
How do I resolve this?

--
Robert W.
Vancouver, BC
www.mwtech.com

Jun 26 '06
12 10134
Right now it's tied in with my own underlying framework. But in the future,
if I can make it more generic, then I will.

I am surprised that MS hasn't come up with a radio button with wrappable
text though. Maybe in a future version!

--
Robert W.
Vancouver, BC
www.mwtech.com

"Ignacio Machin ( .NET/ C# MVP )" wrote:
Hi,
I have OpenNETCF 1.4 installed but unfortunately it doesn't have a
replacement radio button. I seem to be succeeding by using a radio button
with no text and a LinkLabel "connected" to this radio button. Just a
little
bit more tweaking and I should have it working!


May I suggest that you let them know about your new control? maybe they are
interesting in including it in the next version of the framework
--
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

Jun 27 '06 #11

Kevin Spencer wrote:
Whenever you override any base class property, method, event, etc.
using either "override" _or_ "new", you lose the ability to access the
corresponding _base class_ member from outside the class.


That is exactly what I said:
Note: When you hide the inherited member in this way, you lose all access
to it from outside the class. From *inside* the class, you can still get to
it by using base.Width.


Sorry. I should have been more explicit about what I considered
"inaccurate ". I was focusing on the words "in this way": when you hide
the inherited member "in this way" (i.e. using "new") then you lose all
access to it from outside the class.

In fact, if you hide the inherited member in either way: either using
"new" or "override" then you lose access to the base class member from
outside the class. The only exception is if you use "new" to hide the
inherited member, when you can get at the base class member by casting
to a base class reference.

So, in the end I just wanted to clarify your post: what you said was
also true for "override," and there was one exception to what you
stated.

Jun 27 '06 #12
Hi Bruce,

I had not thought of the interpretation of what I said the way you thought
of it. At any rate, by now I'm sure that all possible misunderstandin g has
been erased!

--
;-),

Kevin Spencer
Microsoft MVP
Professional Chicken Salad Alchemist

Big thicks are made up of lots of little thins.
"Bruce Wood" <br*******@cana da.com> wrote in message
news:11******** *************@u 72g2000cwu.goog legroups.com...

Kevin Spencer wrote:
> Whenever you override any base class property, method, event, etc.
> using either "override" _or_ "new", you lose the ability to access the
> corresponding _base class_ member from outside the class.


That is exactly what I said:
>> Note: When you hide the inherited member in this way, you lose all
>> access
>> to it from outside the class. From *inside* the class, you can still
>> get to
>> it by using base.Width.


Sorry. I should have been more explicit about what I considered
"inaccurate ". I was focusing on the words "in this way": when you hide
the inherited member "in this way" (i.e. using "new") then you lose all
access to it from outside the class.

In fact, if you hide the inherited member in either way: either using
"new" or "override" then you lose access to the base class member from
outside the class. The only exception is if you use "new" to hide the
inherited member, when you can get at the base class member by casting
to a base class reference.

So, in the end I just wanted to clarify your post: what you said was
also true for "override," and there was one exception to what you
stated.

Jun 27 '06 #13

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

Similar topics

8
2267
by: Edward Diener | last post by:
Is it possible for a derived class to override a property and/or event of its base class ?
8
6743
by: Massimiliano Alberti | last post by:
Can I specialize a template function in a subclass without overriding it? (the main template function is defined in a base class). Now I'm doing something like that: (in base class) template<class X> void myfunc(X par1) { } (in derived class) template<class X>
10
5213
by: muscha | last post by:
I don't get it. What's the main differences between overriding a base class's methods vs. hiding them? Thanks, /m
4
7012
by: Mark Sizer | last post by:
Hi people, I'm having trouble trying to achieve something in C# and win forms, and am looking for a little advice if anyone has a moment. I've got two classes: 1) a base class 2) a derived class that inherits from it
4
1707
by: Nilesh | last post by:
I am confused about the purpose of 'new' in overriding. Consider following example. <code_snippet> using console = System.Console; public class TestClass { public static void Main() {
4
1933
by: ORi | last post by:
Hi all ! There's a question I've been bothering for a while: I'm actually developing architectural frameworks for application developing and I think virtual methods, although needed because of the flexibility they introduce (flexibility really needed in framework developing), are often a nuisance for final developers. They don't like them because they never know if base class must be called and where should they place the call if...
2
2996
by: MattB | last post by:
Hello I have base class called DocumentManager.cs I then have another class which inherits from DocumentManager which is a TestManager.cs I want to override the base method and want to pass properties on TestManager into DocumentManager, and then load the TestManager properties with values from Document manager.... I am really confused all the examples I can find seem like simple Animal->Dog type instructions. Basically in...
2
3605
by: ESPNSTI | last post by:
Hi, I'm very new to C# and .Net, I've been working with it for about a month. My experience has been mainly with Delphi 5 (not .Net). What I'm looking for is for a shortcut way to override a property without actually having to reimplement the get and set methods. In other words, override the the property without changing the functionality of the base property and without explicitly having to reimplement the get and set methods to make it do...
17
2922
by: Bob Weiner | last post by:
What is the purpose of hiding intead of overriding a method? I have googled the question but haven't found anything that makes any sense of it. In the code below, the only difference is that when the Poodle is upcast to the Dog (in its wildest dreams) it then says "bow wow" where the bernard always says "woof" (see code). Basically, it appears that I'm hiding the poodle's speak method from everything except the poodle. Why would I...
0
9715
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
9595
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
10600
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
10352
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...
0
10097
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9175
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
7642
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...
1
4313
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3835
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.