Groups | Blog | Home
all groups > dotnet compact framework > june 2005 >

dotnet compact framework : Using structs as properties in custom controls


Bjoern Feld
6/30/2005 1:52:04 PM
Hi,

how do I have to decalre a struct in C# to be able to use it as a property
in a custom control?

I do have a custom control with design time support and I want to add a
property similar like the standard Size Property.
Using my control I am not able to access the property. The control Designer
displays it as inactive and the compiler returns:

"Cannot modify the return value of
'TargetControls.TBaseDisplayControl.DisplayValue' because it is not a
variable"

Below is an excerpt of my code

public struct theStruct
{
private int m_i;
private int m_j;
public theStruct(int ii, int jj)
{
m_i=ii;
m_j=jj;
}
}

private Size m_Dummy;
public Size Dummy
{
get
{
return m_Dummy;
}
set
{
m_Dummy = value;
}
}

Thanks,

Tim Wilson
6/30/2005 6:22:43 PM
To give "expandability" to a property through the designer look into the
ExpandableObjectConverter class.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemcomponentmodelexpandableobjectconverterclasstopic.asp

You can find examples of how to use this class through a google search.
http://www.google.com/search?q=ExpandableObjectConverter

--
Tim Wilson
..Net Compact Framework MVP

[quoted text, click to view]

AddThis Social Bookmark Button