This is driving me crazy. I've put together a perfect, easy example of
the problem. What I'm doing is creating a custom control, prepopulated
with 4 items when dropped on a form:
- Create a new Control Library project.
- Inherit System.Windows. Forms.Combobox
- In New(), add this:
Me.Items.Add("T est1")
Me.Items.Add("T est2")
Me.Items.Add("T est3")
Me.Items.Add("T est4")
- Build.
- Start a sample project.
- Drop the new control on the form
- Run.
- Pull down combo:
The combo containts Test1 - Test4, TWICE.
The problem is, when the new control is dropped on a form, it adds
this to the "Windows Form Designer Generated Code":
'
'TestCombo1
'
Me.TestCombo1.I tems.AddRange(N ew Object() {"Test1", "Test2", "Test3",
"Test4"})
Me.TestCombo1.L ocation = New System.Drawing. Point(64, 80)
Me.Morecode...
I can't write any pre-initialized controls because the initialization
is always copied to the application it's being used in, duplicating
the code as demonstrated here. How do I prevent inheritance of the
iniitialization code? (or any code for that matter)
Thanks!!! 2 1130
Use following code can avoid your problem:
Dim myArray As String() = {"Test1", "Test2", "Test3", "Test4"}
Me.DataSource = myArray
Do not need Me.Items.Add("T est1")
Me.Items.Add("T est2")
Me.Items.Add("T est3")
Me.Items.Add("T est4")
any more
"Fred Flintstone" wrote: This is driving me crazy. I've put together a perfect, easy example of the problem. What I'm doing is creating a custom control, prepopulated with 4 items when dropped on a form:
- Create a new Control Library project. - Inherit System.Windows. Forms.Combobox - In New(), add this:
Me.Items.Add("T est1") Me.Items.Add("T est2") Me.Items.Add("T est3") Me.Items.Add("T est4")
- Build. - Start a sample project. - Drop the new control on the form - Run. - Pull down combo:
The combo containts Test1 - Test4, TWICE.
The problem is, when the new control is dropped on a form, it adds this to the "Windows Form Designer Generated Code":
' 'TestCombo1 ' Me.TestCombo1.I tems.AddRange(N ew Object() {"Test1", "Test2", "Test3", "Test4"}) Me.TestCombo1.L ocation = New System.Drawing. Point(64, 80) Me.Morecode...
I can't write any pre-initialized controls because the initialization is always copied to the application it's being used in, duplicating the code as demonstrated here. How do I prevent inheritance of the iniitialization code? (or any code for that matter)
Thanks!!!
Actually, it doesn't. The code below is copied to the application
code and executed again at runtime. Here's the solution:
if not (Me.DesignMode) then
' Add Items....
End if.
Thanks tho...
On Wed, 7 Jul 2004 13:18:02 -0700, "Rulin Hong"
<Ru*******@disc ussions.microso ft.com> wrote: Use following code can avoid your problem:
Dim myArray As String() = {"Test1", "Test2", "Test3", "Test4"} Me.DataSource = myArray
Do not need Me.Items.Add("T est1") Me.Items.Add("T est2") Me.Items.Add("T est3") Me.Items.Add("T est4") any more
"Fred Flintstone" wrote:
This is driving me crazy. I've put together a perfect, easy example of the problem. What I'm doing is creating a custom control, prepopulated with 4 items when dropped on a form:
- Create a new Control Library project. - Inherit System.Windows. Forms.Combobox - In New(), add this:
Me.Items.Add("T est1") Me.Items.Add("T est2") Me.Items.Add("T est3") Me.Items.Add("T est4")
- Build. - Start a sample project. - Drop the new control on the form - Run. - Pull down combo:
The combo containts Test1 - Test4, TWICE.
The problem is, when the new control is dropped on a form, it adds this to the "Windows Form Designer Generated Code":
' 'TestCombo1 ' Me.TestCombo1.I tems.AddRange(N ew Object() {"Test1", "Test2", "Test3", "Test4"}) Me.TestCombo1.L ocation = New System.Drawing. Point(64, 80) Me.Morecode...
I can't write any pre-initialized controls because the initialization is always copied to the application it's being used in, duplicating the code as demonstrated here. How do I prevent inheritance of the iniitialization code? (or any code for that matter)
Thanks!!! This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: BK |
last post by:
I am writing a tiered inheritance structure in ASP.NET and would like
opinions on the best way to accomplish the correct inheritance dynamically.
The page structure is going to look similar to the following:
System...Page
|
MyBasePage
|------------------|--------------------|
CategoryPageOne CategoryPageTwo CategoryPageThree
| | |
|
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 all obvious in VBA which lacks
inheritance. I'm trying the explanation again now.
I often find cases where a limited form of inheritance would eliminate
duplication my code that seems impossible to eliminate otherwise. I'm getting
very...
|
by: Rik Brooks |
last post by:
Hi,
My problem is in trying to extend events in the inheritance heirarchy. I
have a custom control. It has 3 images on it. The custom control consumes the
Click event. In the Click event of each of the images I fire the Click event
of the control. Let's call the control custom_ancestor. I set the images to
have protected access.
Now I inherit from this custom_ancestor and change the bitmaps to something
that I want for a specific...
|
by: Invalidlastname |
last post by:
Hi,
I just read the pattern "Design and Implementation Guidelines for Web
Clients" from MSDN.
Here is my question. In chapter 3,
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpag/html/diforwc-ch03.asp ,
the article mentions using page inheritance to maintain common page layout.
We currently use page inheritance approach to segment the function areas. In
each function area, there is a base page to provide the common...
|
by: Jerry Camel |
last post by:
I'm trying to create a web control button that will change images when you
hover over it. So I created a Web Control project and modified the default
web control to inherit from WebControls.ImageButton..
But it renders as a textbox when I put it on a web form. I even added code
to make sure that the render and onPreRender events are falling back to
MyBase.
(The HTML in the end user browser doesn't have a type attribute in the
html... ...
| |
by: gerry |
last post by:
Is there any way to prevent web.config inheritance in nested web
applications ?
Here is the scenario, a 3rd party asp.net web application installed on an
asp.net intranet site :
http://intranet.company.org
http://intranet.company.org/3rdPartApp
both are configured as applications in IIS.
the subapp is not physcially installed beneath root app
|
by: nyathancha |
last post by:
Hi,
How Do I create an instance of a derived class from an instance of a
base class, essentially wrapping up an existing base class with some
additional functionality. The reason I need this is because I am not
always able to control/create all the different constructors the base
class has. My problem can be described in code as follows ...
/* This is the base class with a whole heap of
constructors/functionality*/
public class Animal
|
by: =?Utf-8?B?SGVsZ2U=?= |
last post by:
Hi!
I have run into a problem with visual inheritance using the VS2005 designer
for Windows Forms.
My goal is to put business logic and common rules for our controls into its
own layer (base classes) so that future changes in these controls are managed
by just modifying this custom layer, and not all the controls of a particular
type.
|
by: RicercatoreSbadato |
last post by:
hi all, i'd like to inherit from a label, how can I do ?
i've tried:
1. making a new Web User Control, then inherit from
System.Web.UI.WebControls.Label but not works!
2. creating a class (.cs file) that inherits from the Label Control
but it didn't work!
any idea ?
|
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...
|
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...
| |
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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...
|
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...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |