Re: Text Property for user control
I have made now the first step:
I think it is a bug of VS2005...
For some reason it seems that the building of the components not works properly...
if I have opened a form with the control -> close visual studio -> open project -> an error on the form appears. I have first to close the form, close the control -> rebuild project. open one time the control and after that it works..
Regards
Hansjörg
Re: Text Property for user control
I have the exact same problem now.
I needed the .Text field exposed in a user derived class of UserControl, so I added the Browsable(true), so now it shows up, but when changed, nothing get written to the file.
Any solution for this problem?
My woraround for now was to add a new field like this
Code:
[Category("Appearance"), Description("wrapper for .Text field")]
public string Title
{
get { return base.Text; }
set { base.Text = value; }
}
which of course is really ugly.
Any better way of exposing the Text field in the designer so it works?
Jesper
Re: Text Property for user control
How about:
Code:
[Browsable(true)]
public new string Text
{
get { return base.Text; }
set { base.Text = value; }
}
Re: Text Property for user control
That does not work.
I first tried override then new, neither works, the property is not written the file.
Re: Text Property for user control
Til now I work also only with the workaround (other property). I had the problem also for a few other controls. I don't have any idea, what is the problem.
Regards
Hansjörg
Re: Text Property for user control
yeah I guess we will just have to live with that bug.
Re: Text Property for user control
I found the answer on the microsoft.public.dotnet.languages.csharp group.
Code:
[EditorBrowsable(EditorBrowsableState.Always), Browsable(true),
DesignerSerializationVisibility(DesignerSerializationVisibility.Visible),
Bindable(true)]
public override string Text
{
get { return base.Text; }
set { base.Text = value; }
}
The important attribute is the DesignerSerializationVisibility one
Jesper
Re: Text Property for user control
It doesn't work too...I think this is a bug of the designer or something else...
Re: Text Property for user control
hm... it works for me. The field shows up in the designed (as before) and when changed and saved, the changes are written correct in the InitializeComponent method, so for me it works correct now.