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,

Bjoern

Re: Using structs as properties in custom controls by Tim

Tim
Thu Jun 30 17:22:43 CDT 2005

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

"Bjoern Feld" <Bjoern Feld@discussions.microsoft.com> wrote in message
news:81617F56-AA39-4660-B230-1931BC1CC6AA@microsoft.com...
> 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,
>
> Bjoern