473,387 Members | 1,791 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.

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 819

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

Similar topics

0
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
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
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
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
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
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
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
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
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
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
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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?
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
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.