473,480 Members | 1,849 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to make the Designer understand my Mew sub

I have a UserControl that must have 2 fields initialized before some of the
prorperties are used. So I added a new New sub with arguments.

If I leave the old New in there the control could be used without initializing
these fields so I removed it.

Now if I try to use it the designer gets upset because there is no New()

Is it posible to use only a New with arguments and still use the control in the
Designer??
Thanks in advance
Nov 20 '05 #1
6 993
This is where using Me.DesignMode is useful, or validating your properites
before you actually use them. The Designer (VSIDE) only calls the 0
argument constructor (unless there is some really fancy attribute I don't
know if). However, like I said, you can just validate your variables, and
when a property is set, call a method to do whatever it is your user control
needs to initialize from the same constructor.

-CJ
"TryingLikeHeck" <tr************@aol.com> wrote in message
news:20***************************@mb-m07.aol.com...
I have a UserControl that must have 2 fields initialized before some of the prorperties are used. So I added a new New sub with arguments.

If I leave the old New in there the control could be used without initializing these fields so I removed it.

Now if I try to use it the designer gets upset because there is no New()

Is it posible to use only a New with arguments and still use the control in the Designer??
Thanks in advance

Nov 20 '05 #2
Lots of code I was hoping to avoid, but I want to use the Designer so I have
to work with its limitations.

Thanks for the info. At least I now know not to keep trying

"CJ Taylor" <no****@blowgoats.com> wrote in message
news:vt************@corp.supernews.com...
This is where using Me.DesignMode is useful, or validating your properites
before you actually use them. The Designer (VSIDE) only calls the 0
argument constructor (unless there is some really fancy attribute I don't
know if). However, like I said, you can just validate your variables, and
when a property is set, call a method to do whatever it is your user control needs to initialize from the same constructor.

-CJ
"TryingLikeHeck" <tr************@aol.com> wrote in message
news:20***************************@mb-m07.aol.com...
I have a UserControl that must have 2 fields initialized before some of

the
prorperties are used. So I added a new New sub with arguments.

If I leave the old New in there the control could be used without

initializing
these fields so I removed it.

Now if I try to use it the designer gets upset because there is no New()

Is it posible to use only a New with arguments and still use the control

in the
Designer??
Thanks in advance


Nov 20 '05 #3
It's really not that bad. Just do some fun tricks with it. like if you run
validation routines inside your properties at all, you can just reset them
to themselves and it will re run it with the same values. i.e.
me.propertyname = me.propertyname

Kinda fun way to do it. =)

-CJ
" active" <ac****@REMOVEa-znet.com> wrote in message
news:uE****************@TK2MSFTNGP11.phx.gbl...
Lots of code I was hoping to avoid, but I want to use the Designer so I have to work with its limitations.

Thanks for the info. At least I now know not to keep trying

"CJ Taylor" <no****@blowgoats.com> wrote in message
news:vt************@corp.supernews.com...
This is where using Me.DesignMode is useful, or validating your properites before you actually use them. The Designer (VSIDE) only calls the 0
argument constructor (unless there is some really fancy attribute I don't know if). However, like I said, you can just validate your variables, and when a property is set, call a method to do whatever it is your user

control
needs to initialize from the same constructor.

-CJ
"TryingLikeHeck" <tr************@aol.com> wrote in message
news:20***************************@mb-m07.aol.com...
I have a UserControl that must have 2 fields initialized before some of
the
prorperties are used. So I added a new New sub with arguments.

If I leave the old New in there the control could be used without

initializing
these fields so I removed it.

Now if I try to use it the designer gets upset because there is no
New()
Is it posible to use only a New with arguments and still use the

control in the
Designer??
Thanks in advance



Nov 20 '05 #4
" active" <ac****@REMOVEa-znet.com> wrote in message
news:uE****************@TK2MSFTNGP11.phx.gbl...
Lots of code I was hoping to avoid, but I want to use the Designer
so I have to work with its limitations.


OK, I'm new to this, but...

Could use add the niladic constructor (assigning "sensible" default
values for use in the Designer) but throw an Exception if its called
from outside the Designer?

Just a thought...
Phill W.
Nov 20 '05 #5
On 11 Dec 2003 13:39:21 GMT, TryingLikeHeck wrote:
I have a UserControl that must have 2 fields initialized before some of the
prorperties are used. So I added a new New sub with arguments.

If I leave the old New in there the control could be used without initializing
these fields so I removed it.

Now if I try to use it the designer gets upset because there is no New()

Is it posible to use only a New with arguments and still use the control in the
Designer??
Thanks in advance


Could you do something like this? As long as you work in debug mode, the
designer can use the parameterless constructor. When you're ready to
compile to release mode, then the code is not included?

#If Debug
Public Sub New()
'Code
End Sub
#Endif

Public Sub New(parameters)
MyBase.New
InitializeComponents
End Sub

Just an idea

--
Chris

To send me an E-mail, remove the underscores and lunchmeat from my E-Mail
address.
Nov 20 '05 #6
* " active" <ac****@REMOVEa-znet.com> scripsit:
Lots of code I was hoping to avoid, but I want to use the Designer so I have
to work with its limitations.


I wouldn't consider this to be a "limitation". It's a good
compromiss...

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #7

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

Similar topics

12
3269
by: Steven T. Hatton | last post by:
This is something I've been looking at because it is central to a currently broken part of the KDevelop new application wizard. I'm not complaining about it being broken, It's a CVS images. ...
9
2799
by: Rajat Tandon | last post by:
Hello there, I am relatively new to the newsgroups and C#. I have never been disappointed with the groups and always got the prompt replies to my queries.This is yet another strange issue, I am...
17
2253
by: stubbsie | last post by:
Hi, I have redesigned our official public government website in .net and it has taken me a few months to redo. I have been the sole designer of the website from its humble beginnning a few years...
4
2102
by: Chris F Clark | last post by:
Please excuse the length of this post, I am unfortunately long-winded, and don't know how to make my postings more brief. I have a C++ class library (and application generator, called Yacc++(r)...
15
6465
by: rizwanahmed24 | last post by:
Hello i have made a custom control. i have placed a panel on it. I want this panel to behave just like the normal panel. The problem i was having is that the panel on my custom control doesnt...
13
5218
by: cj | last post by:
In a project done in 2003 about a year ago I was told to add the SocketWrench code below into the Windows Form Designer generated code area as shown below. #Region " Windows Form Designer...
8
2298
by: TomC | last post by:
I want to bypass the Windows Form Designer in VS, to create a form programmatically. The elements of the form are to be arranged in a table, and I want the size of the table (and therefore the...
4
2624
by: Goran Djuranovic | last post by:
Hi all, I am experiencing a strange thing happening with a "designer.vb" page. Controls I manually declare in this page are automatically deleted after I drop another control on a ".aspx" page. -...
6
3311
by: =?Utf-8?B?bWljaGFlbCBzb3JlbnM=?= | last post by:
Yesterday Visual Studio gave me a strange error both at compiletime and at designtime that had no obvious connection to anything I had changed recently. After some effort tracking down the problem...
0
7055
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
6920
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
7103
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...
1
6758
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
7010
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...
1
4799
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...
0
4499
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
3003
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1311
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 ...

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.