Click here to Skip to main content
16,012,821 members
Home / Discussions / C#
   

C#

 
GeneralRe: Pretty Weird Request Here... Pin
leppie19-Jun-04 5:42
leppie19-Jun-04 5:42 
GeneralRe: Pretty Weird Request Here... Pin
Heath Stewart19-Jun-04 8:27
protectorHeath Stewart19-Jun-04 8:27 
GeneralRe: Pretty Weird Request Here... Pin
matthias s.19-Jun-04 23:37
matthias s.19-Jun-04 23:37 
GeneralRe: Pretty Weird Request Here... Pin
Heath Stewart20-Jun-04 10:00
protectorHeath Stewart20-Jun-04 10:00 
Generalsharing object placed on a form, in all other forms. Pin
Member 114126619-Jun-04 5:02
Member 114126619-Jun-04 5:02 
GeneralRe: sharing object placed on a form, in all other forms. Pin
Heath Stewart19-Jun-04 8:19
protectorHeath Stewart19-Jun-04 8:19 
GeneralRe: sharing object placed on a form, in all other forms. Pin
Member 114126620-Jun-04 1:02
Member 114126620-Jun-04 1:02 
Generalsaving collection automaticaly into form`s code file.(or resource) Pin
Member 114126619-Jun-04 4:52
Member 114126619-Jun-04 4: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;
}
}
}
}

GeneralRe: saving collection automaticaly into form`s code file.(or resource) Pin
Heath Stewart19-Jun-04 8:15
protectorHeath Stewart19-Jun-04 8:15 
Generaldatatable in class, XMLserialization Pin
Member 114126619-Jun-04 4:50
Member 114126619-Jun-04 4:50 
GeneralRe: datatable in class, XMLserialization Pin
Heath Stewart19-Jun-04 8:13
protectorHeath Stewart19-Jun-04 8:13 
GeneralRe: datatable in class, XMLserialization Pin
Member 114126619-Jun-04 23:22
Member 114126619-Jun-04 23:22 
GeneralRe: datatable in class, XMLserialization Pin
Heath Stewart20-Jun-04 9:57
protectorHeath Stewart20-Jun-04 9:57 
QuestionCalling the default ctor from an overloaded ctor? Pin
matthias s.19-Jun-04 3:38
matthias s.19-Jun-04 3:38 
AnswerRe: Calling the default ctor from an overloaded ctor? Pin
leppie19-Jun-04 4:20
leppie19-Jun-04 4:20 
GeneralRe: Calling the default ctor from an overloaded ctor? Pin
matthias s.19-Jun-04 5:12
matthias s.19-Jun-04 5:12 
AnswerRe: Calling the default ctor from an overloaded ctor? Pin
Nick Parker19-Jun-04 4:32
protectorNick Parker19-Jun-04 4:32 
GeneralRe: Calling the default ctor from an overloaded ctor? Pin
matthias s.19-Jun-04 5:14
matthias s.19-Jun-04 5:14 
AnswerRe: Calling the default ctor from an overloaded ctor? Pin
Colin Angus Mackay19-Jun-04 4:41
Colin Angus Mackay19-Jun-04 4:41 
GeneralRe: Calling the default ctor from an overloaded ctor? Pin
Nick Parker19-Jun-04 4:47
protectorNick Parker19-Jun-04 4:47 
GeneralRe: Calling the default ctor from an overloaded ctor? Pin
Colin Angus Mackay19-Jun-04 5:07
Colin Angus Mackay19-Jun-04 5:07 
GeneralRe: Calling the default ctor from an overloaded ctor? Pin
Nick Parker19-Jun-04 5:37
protectorNick Parker19-Jun-04 5:37 
GeneralRe: Calling the default ctor from an overloaded ctor? Pin
matthias s.19-Jun-04 5:10
matthias s.19-Jun-04 5:10 
GeneralRe: Calling the default ctor from an overloaded ctor? Pin
Heath Stewart19-Jun-04 7:19
protectorHeath Stewart19-Jun-04 7:19 
GeneralTwo RTF Questions Pin
XanderSon19-Jun-04 3:18
XanderSon19-Jun-04 3:18 

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.