473,385 Members | 1,622 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

.Net User Controls

Hi,
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.
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;
}
}

}
}

Jul 19 '05 #1
0 1328

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Robert Howells | last post by:
Perhaps I'm just too new at this to pull it off, or perhaps it's just bad architecture. I'd appreciate some feedback on the the wisdom (or lack thereof) in attempting the following: I'm not new...
6
by: Steve Booth | last post by:
I have a web form with a button and a placeholder, the button adds a user control to the placeholder (and removes any existing controls). The user control contains a single button. I have done all...
3
by: Tim::.. | last post by:
Can someone please help.... I'm having major issues with a user control I'm tring to create! I an trying to execute a sub called UploadData() from a user control which I managed to do but for...
8
by: mark.norgate | last post by:
I've run into a few problems trying to use generics for user controls (classes derived from UserControl). I'm using the Web Application model rather than the Web Site model. The first problem...
3
by: Terry Olsen | last post by:
I'm trying to add a domain user to a local group using the code below: Dim LCL As New DirectoryEntry("WinNT://" + Environment.MachineName + ",computer") Dim DOM As New...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.