If I use one of my Usercontrols on a form the IDE does not admit to a
constructor with arguments.
I'm wondering if the 2005 version has improved on this.
I have controls that have properties that absolutely must be set before
other properties are set. Argument to NEW word be a nice way of doing it.
Anyone familiar with 2005 version? 6 1058
" Just Me" <gr****@a-znet.com> schrieb: If I use one of my Usercontrols on a form the IDE does not admit to a constructor with arguments.
I'm wondering if the 2005 version has improved on this.
I have controls that have properties that absolutely must be set before other properties are set. Argument to NEW word be a nice way of doing it.
/How/ should the IDE know what values to pass to the constructor?
--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Sounds like a design issue.
If you require default values then set them in the default new constructor
Sub New()
myclass.new("de f1", "def2")
End
Sub New(arg1 as type, arg2 as type)
...
End Sub
You might also want to check out me.DesignMode property. That way you can
defer execution if you are currently
working with the control in design mode.
If me.designmode then exit sub
hth
Richard
"Herfried K. Wagner [MVP]" <hi************ ***@gmx.at> wrote in message
news:uv******** *****@TK2MSFTNG P14.phx.gbl... " Just Me" <gr****@a-znet.com> schrieb: If I use one of my Usercontrols on a form the IDE does not admit to a constructor with arguments.
I'm wondering if the 2005 version has improved on this.
I have controls that have properties that absolutely must be set before other properties are set. Argument to NEW word be a nice way of doing
it. /How/ should the IDE know what values to pass to the constructor?
-- Herfried K. Wagner [MVP] <URL:http://dotnet.mvps.org/>
Suppose a form contained a usercontrol
When the form was created it could be passed values via its New arguments.
In the form, before InitializeCompo nent() was called, the form would have to
set the argument values for any usercontrols it contained, maybe using the
values passed to it - maybe not (guess the arguments would have to be
module level or they could be local to New and passed to
InitializeCompo nent)
I suppose the IDE could generate default code for New (the code before the
InitializeCompo nent() as it does now for properties
Probably, a little more thought could produce a better approach.
Anyway, I surmise the answer to my question below is: No.
Thanks
"Herfried K. Wagner [MVP]" <hi************ ***@gmx.at> wrote in message
news:uv******** *****@TK2MSFTNG P14.phx.gbl... " Just Me" <gr****@a-znet.com> schrieb: If I use one of my Usercontrols on a form the IDE does not admit to a constructor with arguments.
I'm wondering if the 2005 version has improved on this.
I have controls that have properties that absolutely must be set before other properties are set. Argument to NEW word be a nice way of doing it.
/How/ should the IDE know what values to pass to the constructor?
-- Herfried K. Wagner [MVP] <URL:http://dotnet.mvps.org/>
"Richard Myers" <fa**@address.c om> wrote in message
news:en******** ******@TK2MSFTN GP10.phx.gbl... Sounds like a design issue. If you require default values then set them in the default new constructor
Sub New() myclass.new("de f1", "def2") End
Sub New(arg1 as type, arg2 as type) ... End Sub
Not sure what you telling me I can do. If my usercontrol in on a form, the
IDE generates the call to the usecontrol New. and I'm told :
'Do not modify it using the code editor.
therefore, where are you picturing the statement myclass.new("de f1",
"def2")?
Is your Sub New() above the form's New?
The me.designmode note below is very good to know.
I need that! You might also want to check out me.DesignMode property. That way you can defer execution if you are currently working with the control in design mode.
If me.designmode then exit sub
hth Richard
"Herfried K. Wagner [MVP]" <hi************ ***@gmx.at> wrote in message news:uv******** *****@TK2MSFTNG P14.phx.gbl... " Just Me" <gr****@a-znet.com> schrieb: > If I use one of my Usercontrols on a form the IDE does not admit to a > constructor with arguments. > > I'm wondering if the 2005 version has improved on this. > > I have controls that have properties that absolutely must be set before > other properties are set. Argument to NEW word be a nice way of doing it. /How/ should the IDE know what values to pass to the constructor?
-- Herfried K. Wagner [MVP] <URL:http://dotnet.mvps.org/>
" Just Me" <gr****@a-znet.com> schrieb: Sub New() myclass.new("de f1", "def2") End
Sub New(arg1 as type, arg2 as type) ... End Sub
Not sure what you telling me I can do. If my usercontrol in on a form, the IDE generates the call to the usecontrol New. and I'm told : 'Do not modify it using the code editor.
Simply add both constructors to your control. Provide the parameterless
constructor for the designer and call the parameterized constructor with
default values inside the parameterless constructor.
--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
I got it now.
Thanks to both
"Herfried K. Wagner [MVP]" <hi************ ***@gmx.at> wrote in message
news:%2******** *******@TK2MSFT NGP12.phx.gbl.. . " Just Me" <gr****@a-znet.com> schrieb: Sub New() myclass.new("de f1", "def2") End
Sub New(arg1 as type, arg2 as type) ... End Sub
Not sure what you telling me I can do. If my usercontrol in on a form, the IDE generates the call to the usecontrol New. and I'm told : 'Do not modify it using the code editor.
Simply add both constructors to your control. Provide the parameterless constructor for the designer and call the parameterized constructor with default values inside the parameterless constructor.
-- Herfried K. Wagner [MVP] <URL:http://dotnet.mvps.org/> This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Mark English |
last post by:
I'd like to write a Tkinter app which, given a class, pops up a
window(s) with fields for each "attribute" of that class. The user could
enter values for the attributes and on closing the window would be
returned an instance of the class. The actual application I'm interested
in writing would either have simple type attributes (int, string, etc.),
or attributes using types already defined in a c-extension, although I'd
prefer not to...
|
by: Stefan Behnel |
last post by:
Hi!
frozenset() doesn't behave as the other immutable empty data types in 2.4:
..>>> '' is ''
True
..>>> () is ()
True
..>>> frozenset() is frozenset()
False
|
by: Ganny |
last post by:
Is it possible to write a template function min that takes variable
number of arguments? It should be without using ugly C var args,
arrays, or statically overloading the method for N arguments. Say, min
function which will take N arguments. Any approaches like generative
programming will help?
-Ganesh
|
by: CJ |
last post by:
Okay, same program, different issue. Thanks to the help that I was
given I was able to complete my program to find variables in a list that
were repeated, and display them once, and how many times they appeared in
the list. And it worked great!
But, being the perfectionist that I am, I wanted to make the proggie
allow any size of list, and not have to be recoded every time. So step
one was to not make the program reliant on the list...
|
by: Neo |
last post by:
Why the following code is compilable? The function abc() doesn't take any
arguments, still i can call the function with arbitraty number of arguments.
Even compiler doesn't show any warning. What the standard says?
----- file1.c ------
extern unsigned abc();
int main()
{
unsigned *chip_offset;
abc(&chip_offset, 10);
| |
by: Mark Berry |
last post by:
Hi,
I'm moving from VB6 to VB 2005. Two questions:
1. One book I'm using has syntax like
Dim testConnection as SqlConnection = New
SqlConnection(connectionString)
However, the Help for the Dim statement says, "If you use New, you do not
|
by: aboutjav.com |
last post by:
Hi,
I need some help. I am getting this error after I complete the asp.net
register control and click on the continue button. It crashed when it
tries to get
it calls this Profile property
((string)(this.GetPropertyValue("Address1")));
|
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: 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...
|
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: 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 then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |