Problem Persisting a nested control using the DesignerSerializationVisibility attribute

  • Thread starter Thread starter Andrew Baker
  • Start date Start date
A

Andrew Baker

I have a progress bar which is nested control and I want to persist
the design time properties of this nested control. I thought all I
needed to do was mark it with the
DesignerSerializationVisibility.Content attribute, as below:

[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public ProgressBar ProgressBar
{
get{return _progressBar;}
set{_progressBar = value;}
}

but for some reason the properies are not being persisted, has anyone
got any ideas what I doing wrong?

thanks
andrew
www.vbusers.com
 
Marvellous, thanks v. much!

I scanned the only MS doc I could find at
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/html/custcodegen.asp,
but couldn't find anything about making it readonly. Is there a
particular reason why it has to be read-only?

thanks again
andrew
www.vbusers.com

Claes Bergefall said:
Make the property read-only

/claes

Andrew Baker said:
I have a progress bar which is nested control and I want to persist
the design time properties of this nested control. I thought all I
needed to do was mark it with the
DesignerSerializationVisibility.Content attribute, as below:

[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public ProgressBar ProgressBar
{
get{return _progressBar;}
set{_progressBar = value;}
}

but for some reason the properies are not being persisted, has anyone
got any ideas what I doing wrong?

thanks
andrew
www.vbusers.com
 
No particular reason, just plain sense

Think about it. Why would you want to allow the user
to exchange your internal instance of the progressbar
for another one (which you'll allow by making it read-write)?
You want to expose the internal progressbar so that
the user can manipulate *its* properties, not exchange
it completely.

If the progressbar was inheritable and you provided
a read-write property, the user could exhange it with
whatever weird control they've made so that your code
wouldn't work anymore. Your code relies on the fact
that the control is an instance of a specific class, not
something derived from it.


/claes

Andrew Baker said:
Marvellous, thanks v. much!

I scanned the only MS doc I could find at
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/html/custcodegen.asp,
but couldn't find anything about making it readonly. Is there a
particular reason why it has to be read-only?

thanks again
andrew
www.vbusers.com

"Claes Bergefall" <[email protected]> wrote in message
Make the property read-only

/claes

Andrew Baker said:
I have a progress bar which is nested control and I want to persist
the design time properties of this nested control. I thought all I
needed to do was mark it with the
DesignerSerializationVisibility.Content attribute, as below:

[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public ProgressBar ProgressBar
{
get{return _progressBar;}
set{_progressBar = value;}
}

but for some reason the properies are not being persisted, has anyone
got any ideas what I doing wrong?

thanks
andrew
www.vbusers.com
 
I guess so...

My original thought was that I wanted to deliberately allow the user
to swap the progress bar to any weird and wonderful derived control
that they may have made. Since as long as it supported the same
properties, I didn't really care how they had customised it... Having
said this, it's just a progress bar, so who cares!!!

:)

thanks claes,
andrew

PS. Can't actually believe it still doesn't expose a backcolor and
forecolor/bar color. Had to resort to sendmessage to change it (see
link below 4 details)!

http://www.vbusers.com/codecsharp/codeget.asp?ThreadID=36&PostID=1&NumReplies=0


Claes Bergefall said:
No particular reason, just plain sense

Think about it. Why would you want to allow the user
to exchange your internal instance of the progressbar
for another one (which you'll allow by making it read-write)?
You want to expose the internal progressbar so that
the user can manipulate *its* properties, not exchange
it completely.

If the progressbar was inheritable and you provided
a read-write property, the user could exhange it with
whatever weird control they've made so that your code
wouldn't work anymore. Your code relies on the fact
that the control is an instance of a specific class, not
something derived from it.


/claes

Andrew Baker said:
Marvellous, thanks v. much!

I scanned the only MS doc I could find at
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/html/custcodegen.asp,
but couldn't find anything about making it readonly. Is there a
particular reason why it has to be read-only?

thanks again
andrew
www.vbusers.com

"Claes Bergefall" <[email protected]> wrote in message
Make the property read-only

/claes

I have a progress bar which is nested control and I want to persist
the design time properties of this nested control. I thought all I
needed to do was mark it with the
DesignerSerializationVisibility.Content attribute, as below:

[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public ProgressBar ProgressBar
{
get{return _progressBar;}
set{_progressBar = value;}
}

but for some reason the properies are not being persisted, has anyone
got any ideas what I doing wrong?

thanks
andrew
www.vbusers.com
 
Back
Top