473,320 Members | 1,865 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,320 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;
}
}

}
}

Nov 22 '05 #1
0 728

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...
4
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...
2
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...
0
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...
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...
1
by: Demetri | last post by:
I'm trying to determine if we want to use panels or user controls for our pages. Our primary concern is performance, page loading and posting speed. To illustrate my question, lets use the...
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...
1
by: zeya_bakhtyar | last post by:
Here is the page architecture: Page loads multiple user controls (including nested user controls) dynamically based on parameters provided into place holders. Note: The page only has the logic to...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.