Click here to Skip to main content
16,013,465 members
Home / Discussions / C#
   

C#

 
GeneralRe: Yahoo and C# Pin
MeterMan20-Jun-04 10:43
MeterMan20-Jun-04 10:43 
GeneralRe: Yahoo and C# Pin
eggie519-Jun-04 17:49
eggie519-Jun-04 17:49 
GeneralRe: Yahoo and C# Pin
MeterMan19-Jun-04 18:25
MeterMan19-Jun-04 18:25 
GeneralRe: Yahoo and C# Pin
eggie519-Jun-04 19:21
eggie519-Jun-04 19:21 
GeneralRe: Yahoo and C# Pin
MeterMan20-Jun-04 16:38
MeterMan20-Jun-04 16:38 
GeneralRe: Yahoo and C# Pin
eggie519-Jun-04 19:11
eggie519-Jun-04 19:11 
GeneralRe: saving collection automaticaly into form`s code file. Pin
Mazdak18-Jun-04 22:18
Mazdak18-Jun-04 22:18 
GeneralRe: saving collection automaticaly into form`s code file. Pin
Member 114126618-Jun-04 22:52
Member 114126618-Jun-04 22:52 
I have a component that contain a collection of a struct.
I drag and drop this component on a form. than i chang it collection, i want when i close form at design time, my collection content save automatically with form(into form's code or resource).
I use this attribute :"[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]".
but this attribute can save only simle data type such "int" or "string" or ...
and not work for collection of a struct or class. my collection code is here :
using System;
using System.Collections;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Drawing;
using System.Windows.Forms;
using System.Data ;

namespace DesignerSerializationVisibilityTest
{
// The code for this user control declares a public property of type DimensionData with a DesignerSerializationVisibility
// attribute set to DesignerSerializationVisibility.Content, indicating that the properties of the object should be serialized.

// The public, not hidden properties of the object that are set at design time will be persisted in the initialization code
// for the class object. Content persistence will not work for structs without a custom TypeConverter.

public class ContentSerializationExampleControl : System.Windows.Forms.UserControl
{
private System.ComponentModel.Container components = null;

int _x ;
public int X
{
get{return _x;}
set{_x=value;}
}
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public DimensionData Dimensions
{
get
{
return new DimensionData(this);
}
}

[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public FieldClollectionClass ss
{
get
{
FieldClollectionClass dd=new FieldClollectionClass() ;
FieldColumn fc=new FieldColumn() ;
fc.DisplayName="AAAAAAAAAAA" ;
fc.FieldName="BBBBBBBBBBBBBB" ;
dd.Add(fc) ;
return dd ;
}
}

#region FiledColumnClass
public class FieldColumn
{
private string m_fieldName ;
[ReadOnly(true)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public string FieldName
{
set
{
m_fieldName=value ;
}
get
{
return m_fieldName ;
}
}
public void SetFieldName(string f)
{
m_fieldName=f ;
}

private string m_displayName ;
public string DisplayName
{
get
{
return m_displayName ;
}
set
{
m_displayName=value ;
}
}

private DataTable m_columnDataTable ;
public DataTable ColumnDataTable
{
get
{
return m_columnDataTable ;
}
set
{
m_columnDataTable=value ;
}
}

private bool m_isKey ;
public bool IsKey
{
get
{
return m_isKey ;
}
set
{
m_isKey=value ;
}
}

private string m_childTableValue ;
//[DefaultValue("code")]
public string ChildTableValue
{
get
{
return m_childTableValue ;
}
set
{
m_childTableValue=value ;
}
}

private string m_childTableName ;
//[DefaultValue("name")]
public string ChildTableName
{
get
{
return m_childTableName ;
}
set
{
m_childTableName=value ;
}
}

private int m_width ;
public int Width
{
get
{
return m_width ;
}
set
{
m_width=value ;
}
}

private bool m_visible ;
//[DefaultValue(true)]
public bool Visible
{
get
{
return m_visible ;
}
set
{
m_visible=value ;
}
}
}
#endregion
[TypeConverterAttribute(typeof(System.ComponentModel.ExpandableObjectConverter))]
public class FieldClollectionClass : CollectionBase
{
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public FieldColumn this[int index]
{
get
{
return( (FieldColumn) List[index] );
}
set
{
List[index] = value;
}
}
public int Add( FieldColumn value )
{
return( List.Add( value ) );
}
public int IndexOf( FieldColumn value )
{
return( List.IndexOf( value ) );
}
public void Insert( int index, FieldColumn value )
{
List.Insert( index, value );
}
public void Remove( FieldColumn value )
{
List.Remove( value );
}
public bool Contains( FieldColumn value )
{
// If value is not of type FieldColumn, this will return false.
return( List.Contains( value ) );
}
}




public ContentSerializationExampleControl()
{
InitializeComponent();
}

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

private void InitializeComponent()
{
components = new System.ComponentModel.Container();
}
}

[TypeConverterAttribute(typeof(System.ComponentModel.ExpandableObjectConverter))]
// This attribute indicates that the public properties of this object should be listed in the property grid.
public class DimensionData
{
private Control owner;

// This class reads and writes the Location and Size properties from the Control which it is initialized to.
internal DimensionData(Control owner)
{
this.owner = owner;
}

public Point Location
{
get
{
return owner.Location;
}
set
{
owner.Location = value;
}
}

public Size FormSize
{
get
{
return owner.Size;
}
set
{
owner.Size = value;
}
}
}
}

QuestionNewbie Q: C# ASPX Popup? Pin
Joel, Just Joel18-Jun-04 16:04
Joel, Just Joel18-Jun-04 16:04 
AnswerRe: Newbie Q: C# ASPX Popup? Pin
Heath Stewart18-Jun-04 18:37
protectorHeath Stewart18-Jun-04 18:37 
GeneralRe: Newbie Q: C# ASPX Popup? Pin
Joel, Just Joel21-Jun-04 15:34
Joel, Just Joel21-Jun-04 15:34 
GeneralFind me that record... Pin
aberger5618-Jun-04 12:05
aberger5618-Jun-04 12:05 
GeneralRe: Find me that record... Pin
Nick Parker18-Jun-04 13:36
protectorNick Parker18-Jun-04 13:36 
GeneralRe: Find me that record... Pin
aberger5619-Jun-04 15:33
aberger5619-Jun-04 15:33 
GeneralHelp MapXtreme Pin
hxxbin18-Jun-04 11:18
hxxbin18-Jun-04 11:18 
GeneralRe: Help MapXtreme Pin
Dave Kreskowiak18-Jun-04 12:49
mveDave Kreskowiak18-Jun-04 12:49 
Generalreleasing PictureBox's Image file handle Pin
ABean18-Jun-04 9:45
ABean18-Jun-04 9:45 
GeneralRe: releasing PictureBox's Image file handle Pin
ABean18-Jun-04 10:12
ABean18-Jun-04 10:12 
GeneralRe: releasing PictureBox's Image file handle Pin
Dave Kreskowiak18-Jun-04 12:47
mveDave Kreskowiak18-Jun-04 12:47 
GeneralCatch and exit Pin
StephenMcAllister18-Jun-04 9:06
StephenMcAllister18-Jun-04 9:06 
GeneralRe: Catch and exit Pin
Nick Parker18-Jun-04 9:39
protectorNick Parker18-Jun-04 9:39 
GeneralEver growing threads and handles Pin
mitchellguzman18-Jun-04 8:49
professionalmitchellguzman18-Jun-04 8:49 
GeneralRe: Ever growing threads and handles Pin
Daniel Turini18-Jun-04 9:42
Daniel Turini18-Jun-04 9:42 
GeneralHandling disposed event. Pin
Member 114461718-Jun-04 8:20
Member 114461718-Jun-04 8:20 
GeneralRe: Handling disposed event. Pin
Heath Stewart18-Jun-04 18:32
protectorHeath Stewart18-Jun-04 18:32 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.