Mark Olbert
2/15/2007 4:25:00 PM
A point of clarification: the crash occurs when I clikc on the Add button in the property editor that comes up when I try to add a
step to the step collection. Making DynamicSelectorStep publicly-constructable doesn't solve the problem.
- Mark
On Thu, 15 Feb 2007 07:39:14 -0800, Mark Olbert <ChairmanMAO@newsgroups.nospam> wrote:
>I'm in a bit of a pickle here: I've got some kind of problem involving persisting some complex properties on a custom control, but
>because VS2005 SP1 keeps crashing when it encounters the problem I'm at a loss as to how to figure out what's wrong.
>
>Here's a sketch of the custom control and properties:
>
>[ToolboxData("<{0}:DynamicSelector runat=server></{0}:DynamicSelector>")]
>[Designer(typeof(DynamicSelectorDesigner))]
>[ParseChildren(false)]
>[PersistChildren(false)]
>[ControlBuilder(typeof(DynamicSelectorBuilder))]
>public class DynamicSelector : CompositeDataBoundControl
>{
> private List<DynamicSelectorStep> steps = new List<DynamicSelectorStep>();
>
> [Category("Data")]
> [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
> [PersistenceMode(PersistenceMode.InnerProperty)]
> public List<DynamicSelectorStep> Steps
> {
> get { return steps; }
> }
>}
>
>Here's the base class of the various objects I trying to persist:
>
>public class DynamicSelectorStep
>{
> public event DynamicSelectorDataHandler DataBinding;
> public event EventHandler Completed;
>
> private string title;
> private int selectedID = -1;
> private DataBindType dataNeed = DataBindType.Unknown;
>
> protected DynamicSelectorStep()
> {
> }
>
> [NotifyParentProperty(true)]
> public string Title
> {
> get { return title; }
> set { title = value; }
> }
>
> [Browsable(false)]
> public virtual string ErrorMessage
> {
> get { return String.Empty; }
> }
>
> [Browsable(false)]
> public virtual bool IsValid
> {
> get { return true; }
> }
>
> [Browsable(false)]
> public int Value
> {
> get { return selectedID; }
> set { selectedID = value; }
> }
>
> [Browsable(false)]
> public DataBindType DataNeed
> {
> get { return DataNeed; }
> set { dataNeed = value; }
> }
>
> public virtual WizardStep CreateWizardStep()
> {
> return null;
> }
>
> public virtual void Initialize()
> {
> }
>
> public virtual void DataBind( IEnumerable data )
> {
> }
>
> protected virtual void OnDataBinding( DataBindType dataNeed, string arg )
> {
> // store what we need for the next step
> this.dataNeed = dataNeed;
>
> if( DataBinding != null ) DataBinding(this, new DynamicSelectorDataArgs(this, dataNeed, arg));
> }
>
> protected virtual void OnCompleted()
> {
> if( Completed != null ) Completed(this, EventArgs.Empty);
> }
>
> internal virtual string DesignTimeHtml
> {
> get { return String.Empty; }
> }
>}
>
>The crash occurs after I open the property editor for Steps in the designer and then close it. It crashes whether or not I've tried
>to add a new step.
>
>BTW, how do I inform the property editor for Steps that there are derived classes that can be added to the collection, as well, and
>that the base class can't be added?
>
>- Mark