I am trying to create a control, using standard user components A.
The I use that component A as part of a new component B.
And finally I drop that component B on my form.
Now in Component A I filled in some default fields like this.
[Browsable(true)]
[DefaultValue("T itle"), Category("Appea rance")]
override public System.String Text {
set {
Title.Text=valu e;
Title.Invalidat e(true);}
get {return Title.Text;}
}
So on the Component B I changed the "Title" to something else (in this case
X-Axis) using the property editor, this works nice.
But when I run the program then the original Title is put there while then
it should be the "X-Axis"
Has anyone have experience with this?
Did I miss something? Some initialization order?
Currently I solve the problem by forcing it in the main form
programatically . 4 1255
Hi Olaf,
if i understand what you trying , since the control B derrives from control
A, when you put the control B in a form it overrides the B.Text in the
InitializeCompo nents () function. try to set the Text property of the
control B in your form from the property Window to "", this will delete the
line B.Text = "B"; from the InitializeCompo nents () function and will have
the default value of the A control.
If that works tel me about it cos i haven try it.
"Olaf Baeyens" <ol**********@s kyscan.be> wrote in message
news:42******** *************@n ews.skynet.be.. . I am trying to create a control, using standard user components A. The I use that component A as part of a new component B. And finally I drop that component B on my form.
Now in Component A I filled in some default fields like this.
[Browsable(true)] [DefaultValue("T itle"), Category("Appea rance")] override public System.String Text { set { Title.Text=valu e; Title.Invalidat e(true);} get {return Title.Text;} }
So on the Component B I changed the "Title" to something else (in this case X-Axis) using the property editor, this works nice.
But when I run the program then the original Title is put there while then it should be the "X-Axis"
Has anyone have experience with this? Did I miss something? Some initialization order? Currently I solve the problem by forcing it in the main form programatically .
> if i understand what you trying , since the control B derrives from
control A, when you put the control B in a form it overrides the B.Text in the InitializeCompo nents () function. try to set the Text property of the control B in your form from the property Window to "", this will delete
the line B.Text = "B"; from the InitializeCompo nents () function and will have the default value of the A control. If that works tel me about it cos i haven try it.
I think that is what I tried to explain.
But on the web I found some examples how to fix this. Only the big trouble
is that it is very hard to understand what they try to explain, so when I
have a workable solution then I will post ik back.
I think I start to understand what is going on.
Maybe my explanation was not that good.
I have a user control A that contains a,b,c
I fill in a.Text="text" in the property editor.
Now I create a control B, that contains 2 A controls.
And I change the a.Text of control A on the B control using the property
editor to "Test 2"
I keep the control B visible on screen and recompile and wonder over wonder
the string "Test 2" gets replaced by to older "text".
So my executable incorrecly shows the older "text" string instead of the new
"Test 2".
But when I add this:
private void B_Load(object sender, System.EventArg s e) {
A.Text="Test 2";
}
The the label is correctly shown, but is a hack since it overrides the
property editor's choice programatically .
My guess is that B instantiates A, and any value given in B is overridden by
the fact that A gets instantiated later.
Is there a good trechnique for fixing this?
Odd I open the B control in design view.
I select the first A control, and in the property editor I change the "Text"
property to another string.
I see visually that the B control has the new updated text, and the property
editor also shows the text.
I save all files.
I close the B control dialog box.
Open it again and the original text is back, not the one I edited.
If I look inside the genarated B.cs code then I do not see the A.Text
property initialized in the "private void InitializeCompo nent()" part of
control B.cs.
It could because I created my own text property for A. (because A is
composed of 3 standard controls and one of it is a label, that shows that
A.Text string.
This is the definition of that A.Text property, is something missing?
private System.Windows. Forms.Label Title;
[Browsable(true)]
[DefaultValue("T itle"), Category("Appea rance")]
[Description("Th e title")]
override public System.String Text {
set {
Title.Text=valu e;
Title.Invalidat e(true);
}
get {return Title.Text;}
} This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Todd D. Levy |
last post by:
I have a table of Country names & Country codes in alphabetical order.
This is a lookup table that a number of other tables use to populate the
Country field via a drop down Combo Box on the form(s) for the table(s)
in question.
The "United States" Country name & the "US" Country code are selected
99% of the time.
I would like to have the "United States" & "US" be the default values
|
by: jerome g |
last post by:
Hi,
I'm trying to use a (simple) form to create a new record, with all
values being default values coming from a previous form. My problem is
that I can save that new record only if I change one of the default
values, something which is not supposed to be done. So is there a way
to create the record without making any change to the 'default form'?
Thank you for your help!
JeromeG
|
by: countd4 |
last post by:
I have built a working user control. However, to make it work, I always have
to set certian properties using the properties sheet for the control when
using it on other forms. I want to be able to set default values for most
properties so the control will work as-is without requiring the developer to
set them.
I notice in the compment initialization code create when I drop the control
on a form that all the properties are set to null or...
|
by: Viorel |
last post by:
Adding new row with default values.
In order to insert programmatically a new row into a database table, without
direct "INSERT INTO" SQL statement, I use the well-known DataTable.NewRow,
DataTable.Rows.Add and DataAdapter.Update member functions. Before adding
the new row object to the Rows collection, all of the row's fields that do
not accept NULL must be assigned, otherwise an exception is thrown. However,
I do not want to assign...
|
by: Aaron Smith |
last post by:
How do I set field default values at runtime? Say I want a check box
that is bound to a boolean field to default to false for a certain set
of criteria, and then true for others? I also need to do this with other
fields, not just boolean....
Thanks,
Aaron
--
---
Aaron Smith
| |
by: Charlie |
last post by:
Imagine I subclass Panel into MyPanel and set a few property values to my
own defaults as shown below. Eg. I set BackColor to by LightYellow.
When I add MyPanel to a form, it will write the non-default property values
into the InitializeComponent of the form. So it will explicitily set
myPanel1.BackColor = Color.LightYellow. If I later change the MyPanel
BackColor default from LightYellow to LightRed, it will not reflect this in
my form...
|
by: helenwheelss |
last post by:
Access 2003, using a bound form.
I'm seeing rather annoying behaviour when editing data in a control
with a default value. It only happens when the form is on a new
record.
A specific example: on my form, the first control is bound to a date/
time field and has a default value of now(). When users need to change
this control's data, they'll most commonly need to alter the time part
leaving the date as is. But, on a new record, when...
|
by: Whasigga |
last post by:
Hi
I've created a form that has 7 subforms. It is the same subform, bound to a table, just repeated. This form represents a week, and each subform is used to enter in data for each day of the week. The main form has a combo box that must have a value selected before anything else can happen. Once that value is selected, the 7 subforms are enabled, and also one of the fields is populated with the value from the main form. These subforms also...
|
by: peterkennett |
last post by:
I am designing a database that will be used by many different offices, and each office may want to change the defaults I have in a table.
Rather than teach each user how to go in and change a table's default values, I want to create a user-friendly form that allows them to change the default values in the linked table.
Let's say I have a form field "office" on my form that is linked to the table field in my table. The field has a...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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: 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: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |