Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > .NET 1.0 and Visual Studio.NET > VS.NET 2002/2003
|
VS.NET 2002/2003 Discussions about the Visual Studio.NET programming environment, the 2002 (1.0) and 2003 (1.1). ** Please don't post code questions here ** For issues specific to a particular language in .NET, please see the other forum categories.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VS.NET 2002/2003 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 15th, 2003, 04:03 AM
Registered User
 
Join Date: Aug 2003
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Subhash1275
Default .Net User Controls - Property Persistance Prob

Hi, :D
    We have a prob with .Net User Controls, something like this. I have a Custon Control InfoLabel Derived from System.Windows.Forms.Label ( Direct Inheritance - Custom Control) and the some properties of this is held in one custon Class.
By setting TypeConverter attribute to the above class we could make it the subproperty. AS a singale control its working fine.
Now, We have created another User Control, InfoMultiLabel, that uses this control (Not inheriting but simply 2 contols of earlier one - the InfoLabel). These two InfoLables are exposed as sub properties so that its properties can be set differently for each (eg one balck and another blue). OK we could set the properties at design time. But the propb is its value not Getting serialed and hence when after closing the forn and reopening the already set values are removed. (design time property no persisiting once closed and re opened).
Any idea abt this. What attribute should be given to make this property persisitng? Can it be done?. I have duplicated the prob with a small code, given below. Any help is highly appreciated.

TQ :D


using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;

namespace Test
{
    public class Test : System.Windows.Forms.UserControl
    {
        private System.Windows.Forms.Label label1;
        private System.ComponentModel.Container components = null;

        public Test()
        {
            InitializeComponent();
        }

        protected override void Dispose( bool disposing )
        {
            if( disposing )
            {
                if(components != null)
                {
                    components.Dispose();
                }
            }
            base.Dispose( disposing );
        }

        #region Component Designer generated code
        private void InitializeComponent()
        {
            this.label1 = new System.Windows.Forms.Label();
            this.SuspendLayout();
            //
            // label1
            //
            this.label1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
            this.label1.Location = new System.Drawing.Point(48, 16);
            this.label1.Name = "label1";
            this.label1.TabIndex = 0;
            this.label1.Text = "label1";
            //
            // Test
            //
            this.Controls.Add(this.label1);
            this.Name = "Test";
            this.Size = new System.Drawing.Size(184, 64);
            this.Load += new System.EventHandler(this.Test_Load);
            this.ResumeLayout(false);

        }
        #endregion

        private void Test_Load(object sender, System.EventArgs e)
        {
        }

        /// <summary>
        /// Property for setting the ForeColor
        /// </summary>
        [Category( "Controls" )]
        [Description( "Property for setting the InfoLabel Control" )]
        [DefaultValue( typeof(Label),"Label" )]
        [DesignerSerializationVisibility(DesignerSerializat ionVisibility.Content)]
        public Label InfoLabel // <<<<<<<<------ NOT Serializing this Value
        {
            get { return label1; }
            set
            {
                label1 = value;
            }
        }

    }
}








Similar Threads
Thread Thread Starter Forum Replies Last Post
Persist Property Values In Controls. jahanzaib.attari ASP.NET 2.0 Basics 1 September 21st, 2007 09:19 AM
User controls' content: Chapter 2 User Controls AGS BOOK: Professional ASP.NET 2.0 Server Control and Component Development ISBN: 978-0-471-79350-2 10 July 26th, 2007 05:36 AM
DropDownList User controls asp.net 2.0 ButtonsBob ASP.NET 1.0 and 1.1 Basics 1 January 9th, 2006 06:18 AM
VB6 to .NET User Controls mckly VB.NET 2002/2003 Basics 1 June 23rd, 2004 09:39 AM
User Controls - Property as object Subhash1275 VS.NET 2002/2003 1 August 12th, 2003 05:45 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.