473,503 Members | 9,887 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Augmenting default controls with inheritance doesn't work, is there a fix?

I want to augment a standard control like this:

public class MyButton : System.Windows.Forms.Button
{
public MyButton()
{
this.FlatStyle = System.Windows.Forms.FlatStyle.Standard;
}
}

Then I want to change, for instance, the color from LightBlue to Blue for
all the places where MyButton is used by changing a line in the constructor
to:

this.FlatStyle = System.Windows.Forms.FlatStyle.Flat;

However this does not propagate to all the places where MyButton was used.
VS automatically adds this line of code in InitializeComponent() every time
the button is dropped onto a form:

this.myButton1.FlatStyle = System.Windows.Forms.FlatStyle.Standard;

The above line overrides my constructor style change.

Is there a way around this problem so that I can use MyButton everywhere and
easily change the attributes so that all instances use my new settings?

I'm using VS .NET 2002, if that makes a difference.

Thanks.
Nov 22 '05 #1
0 820

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

Similar topics

0
241
by: Dave L | last post by:
I want to augment a standard control like this: public class MyButton : System.Windows.Forms.Button { public MyButton() { this.FlatStyle = System.Windows.Forms.FlatStyle.Standard; } }
11
1670
by: ThunderMusic | last post by:
Hi, I'm currently stuck with a big problem. I must develop a Windows service and an application to configure it and display what is happening. The problem is not really on the service side, but on...
14
12878
by: Steve Jorgensen | last post by:
Recently, I tried and did a poor job explaining an idea I've had for handling a particular case of implementation inheritance that would be easy and obvious in a fully OOP language, but is not at...
2
2598
by: Rachel Suddeth | last post by:
Here is my scenario: I have a few custom controls that I set up on a form and tested setting properties and appearances. Then I added a couple references to the project which add classes I need to...
2
1311
by: Greg | last post by:
There is a repeating issue of controls vanishing from a form in the Dev environment which is starting to get annoying. What happens is that I will have a form open in the IDE. The form will have...
0
2210
by: Frnak McKenney | last post by:
I'm running into problems with VisualStudio.NET2003 and Windows Forms inheritance. It _feels_ like a bug, but it could just as well be a misunderstanding on my part regarding how the VS Designer...
4
1095
by: sonic | last post by:
Hello, I am trying to create a custom control hierarchy that encapsulates web controls in my framework and run into a interesting problem. my framework will automatically save all user control...
8
3156
by: mark.norgate | last post by:
I've run into a few problems trying to use generics for user controls (classes derived from UserControl). I'm using the Web Application model rather than the Web Site model. The first problem...
4
16230
by: Mikus Sleiners | last post by:
I can't seem to add new controls to form that is inherited from another form. I have BaseForm wich have table layout on it 2 panelsm and some buttons. Now i create InheritedForm : BaseForm and...
4
5221
by: Jon Harrop | last post by:
I am writing a 3D graphing component built upon WPF and would like to have 2D vector graphics (e.g. typeset mathematics) as labels laid out from 3D coordinates. For example, a tick on an axis has a...
0
7207
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
7095
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...
1
7015
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...
0
5602
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,...
0
4693
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3173
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1523
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 ...
1
749
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
403
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.