|
-
February 28th, 2006, 03:59 AM
#1
Text Property for user control
Hello,
at the moment I create a usercontrol. I wan't to have for that a text property. But I don't have any idea, why my solution doesn't work...
Code:
[
Category("Appearance"),
Description("The text associated with the control.")
]
public string Text
{
get { return text; }
set { text = value; }
}
Regards
Hansjörg
-
February 28th, 2006, 04:15 AM
#2
Re: Text Property for user control
The control class (the base class of all user controls) already has the Text property..Why do you want to add your own?
You can override OnTextChanged method to add your special logic or override the Text property itself.
-
February 28th, 2006, 04:19 AM
#3
Re: Text Property for user control
I don't want a new Text propertie. I want to see and edit the text property in the property editor (at the moment I don't see it there), because I want to display the text in a label inside the usercontrol.
What is the best way for that?
Regards
hansjörg
-
February 28th, 2006, 04:24 AM
#4
Re: Text Property for user control
try to add the Browsable attribute:
Code:
[Browsable(true)]
public override string Text
{
get
{
return text;
}
set
{
text = value;
}
}
-
February 28th, 2006, 04:57 AM
#5
Re: Text Property for user control
Great it works. Is there also a possibility to bind the text property of a label to this text property? It would be great if I can see the text also in the designer
Regards and many thanks
Hansjörg
-
February 28th, 2006, 05:33 AM
#6
Re: Text Property for user control
Solved. I can set the property of the label only inside the Property Text
Thanks
Hansjörg
-
March 1st, 2006, 02:54 AM
#7
Re: Text Property for user control
Hello,
during the test I have found out that the text-Property is not saved if I close the form.
What I have to do to save it?
Regards
Hansjörg
-
March 1st, 2006, 04:55 PM
#8
Re: Text Property for user control
 Originally Posted by hansipet
Hello,
during the test I have found out that the text-Property is not saved if I close the form.
What I have to do to save it?
Regards
Hansjörg
strange
Please send the code of the property..or upload the code file.
-
March 2nd, 2006, 01:33 AM
#9
Re: Text Property for user control
Code:
public partial class ConnectionDeviceSettingsCtrl : UserControl{
private string text;
[Browsable(true)]
public override string Text
{
get { return text; }
set
{
this.text = value;
connectionDevSettings.Text = value;
}
}
private System.Windows.Forms.GroupBox connectionDevSettings;
}
Regards and many thanks for your help!
-
March 2nd, 2006, 02:30 AM
#10
Re: Text Property for user control
So..When you close the form designer and reopen it ,, you lose the last Text value...
This is so strange..I did not face this problem before..
-
March 2nd, 2006, 03:02 AM
#11
Re: Text Property for user control
Yes I loose this property. I have another strange problem in this workspace.
If the control where the usercontrol is placed is open during closing my visualstudio 2005 express edition.
- control where the above usercontrol is used is open in designer
- close VS 2005 express edition
- open VS 2005 express edition
- open this project -->
Receive warnings:
Warning 1 Exception has been thrown by the target of an invocation. D:\daten\projekte\c#\NetWorkManagerDev\NetworkManager\View\ConfigCtrl.Designer.cs 531 0
Warning 2 Could not load file or assembly 'Ethernet, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. Das System kann die angegebene Datei nicht finden. D:\daten\projekte\c#\NetWorkManagerDev\NetworkManager\View\ConfigCtrl.Designer.cs 538 0
Warning 3 Could not load file or assembly 'Ethernet, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. Das System kann die angegebene Datei nicht finden. D:\daten\projekte\c#\NetWorkManagerDev\NetworkManager\View\ConfigCtrl.Designer.cs 537 0
Warning 4 Could not find type 'Ethernet.NetworkManager.Data.DeviceConnectionList'. Please make sure that the assembly that contains this type is referenced. If this type is a part of your development project, make sure that the project has been successfully built. D:\daten\projekte\c#\NetWorkManagerDev\NetworkManager\View\ConfigCtrl.Designer.cs 514 0
I don't know why. May be the two things are associated..
Regards
Hansjörg
-
March 2nd, 2006, 03:04 AM
#12
Re: Text Property for user control
sorry I saw that some parts of the warnings are in german.
Das System kann die angegebene Datei nicht finden.
means
The system can't find the file
-
March 2nd, 2006, 01:14 PM
#13
Re: Text Property for user control
Try to rebuild the control separately..then add it again to the form designer..
-
March 3rd, 2006, 01:10 AM
#14
Re: Text Property for user control
What do you mean with build seperatly and add it to the form designer. Do you mean build the project seperatly and add it than to the VS2005 workspace?
Regards
Hansjörg
-
March 3rd, 2006, 01:58 AM
#15
Re: Text Property for user control
No
delete the control from the form
then build the control project
then add it again to the form..
another last option:
remove the control project from the workspace..
build it
add it to the control box as an assemble..then drag and drop it on the form.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|