Windows Develop Bookmark and Share   
 index > Windows Forms Designer > Publishing properties
 

Publishing properties

Hi, i wrote this class/component:

Code Snippet

using System;

using System.Collections.Generic;

using System.Text;

using System.ComponentModel;

namespace MyComponentSet

{

public class FontStyle

{

private bool _fsBold = false;

private bool _fsItalic = false;

private bool _fsStrikeOut = false;

public FontStyle()

{

}

public FontStyle(bool fsBold, bool fsItalic, bool fsStrikeOut)

{

this.FsBold = fsBold;

this.FsItalic = fsItalic;

this.FsStrikeOut = fsStrikeOut;

}

~FontStyle()

{

}

public override string ToString()

{

return String.Format("FsBold = {0}, FsItalic = {1}, FsStrikeOut = {2}", new Object[] { FsBold.ToString(), FsItalic.ToString(), FsStrikeOut.ToString() });

}

public bool FsBold

{

get { return _fsBold; }

set

{

if (!value.Equals(_fsBold))

{

_fsBold = value;

}

}

}

public bool FsItalic

{

get { return _fsItalic; }

set

{

if (!value.Equals(_fsItalic))

{

_fsItalic = value;

}

}

}

public bool FsStrikeOut

{

get { return _fsStrikeOut; }

set

{

if (!value.Equals(_fsStrikeOut))

{

_fsStrikeOut = value;

}

}

}

}

public class MyComponent : System.ComponentModel.Component

{

private FontStyle _fontStyle;

public MyComponent()

{

_fontStyle = new FontStyle();

}

[Description("Font Style."), Browsable(true)]

public FontStyle FontStyle

{

get { return _fontStyle; }

set

{

if (!value.Equals(_fontStyle))

{

_fontStyle = value;

}

}

}

}

}

When i drop MyComponent into the form, the property FontStyle has no plus signal to expand the subproperties.

The Method ToString() returns "MyComponentSet.MyComponent" and in the Properties Window, the value os the FontStyle is "FsBold = False, FsItalic = False, FsStrikeOut = False".

What is wrong?

Thanks.

Alessandro Moacyr Duarte  Thursday, April 12, 2007 5:06 PM

Put a TypeConverterAttribute on top of the FontStyle class:

[TypeConverter(typeof(ExpandableObjectConverter))]

public class FontStyle ...

If you want to have it more sophisticated, implement your own object converter, take a look at:

http://msdn2.microsoft.com/en-us/library/aa302334.aspx

John.Doe  Thursday, April 12, 2007 5:18 PM

Put a TypeConverterAttribute on top of the FontStyle class:

[TypeConverter(typeof(ExpandableObjectConverter))]

public class FontStyle ...

If you want to have it more sophisticated, implement your own object converter, take a look at:

http://msdn2.microsoft.com/en-us/library/aa302334.aspx

John.Doe  Thursday, April 12, 2007 5:18 PM

Thank you John.Doe
Your tip worked very well.

Alessandro Moacyr Duarte  Friday, April 13, 2007 1:12 PM

You can use google to search for other answers

Custom Search

More Threads

• Windows Designer not describing an object property completely.
• UserControl TestContainer -- Startup Control determined by ?
• What is Regular Expression for US Phone Number(Windows application)?
• Difference between design-time and run-time execution
• Listbox is always closed
• Designer Crashes Visual Studio
• Per Pixel Alpha Blend in Control ??
• how to host different controls in the same column in DataGridView control
• Double-click event handler generation in Form Designer
• ApplicationSettings upgrading problem