Problem in showing the custom Csharp propertyin Properties window

  • Thread starter Thread starter Pasan Indeewara
  • Start date Start date
P

Pasan Indeewara

Hi,
In my customized control, it has below small coding..

[System.ComponentModel.Browsable(true)]
public int RouteNo
{
get{ return RouteNo;}
set { RouteNo = value; grpRoute.Text = "Route -
"+RouteNo.ToString(); }
}

when I put any custom properties like this Visual studio quits and
says 'Visual Studio unexpectedly closed.' message. If I commented above and
all other places where I have used this property, it works fine.

Attached is my custom control. Any help?
 
Pasan said:
Hi,
In my customized control, it has below small coding..

[System.ComponentModel.Browsable(true)]
public int RouteNo
{
get{ return RouteNo;}
set { RouteNo = value; grpRoute.Text = "Route -
"+RouteNo.ToString(); }
}

when I put any custom properties like this Visual studio quits
and says 'Visual Studio unexpectedly closed.' message. If I commented
above and all other places where I have used this property, it works fine.

Looks like an infinite recursion. The normal pattern for properties would
include a private backing field for the property RouteNo - one with a different
name to avoid the recursion.

HTH,
-rick-
 
Rick Lones said:
Pasan said:
Hi,
In my customized control, it has below small coding..

[System.ComponentModel.Browsable(true)]
public int RouteNo
{
get{ return RouteNo;}
set { RouteNo = value; grpRoute.Text = "Route -
"+RouteNo.ToString(); }
}

when I put any custom properties like this Visual studio quits and
says 'Visual Studio unexpectedly closed.' message. If I commented above
and all other places where I have used this property, it works fine.

Looks like an infinite recursion. The normal pattern for properties would
include a private backing field for the property RouteNo - one with a
different name to avoid the recursion.

HTH,
-rick-

Hi Rick,
Thanks for the help. I had previously worked with VFP and in that this
was possible, So I never had a thought this will end up in a infinite
recursion.
 
Rick Lones said:
Pasan said:
Hi,
In my customized control, it has below small coding..

[System.ComponentModel.Browsable(true)]
public int RouteNo
{
get{ return RouteNo;}
set { RouteNo = value; grpRoute.Text = "Route -
"+RouteNo.ToString(); }
}

when I put any custom properties like this Visual studio quits and
says 'Visual Studio unexpectedly closed.' message. If I commented above
and all other places where I have used this property, it works fine.

Looks like an infinite recursion. The normal pattern for properties would
include a private backing field for the property RouteNo - one with a
different name to avoid the recursion.

HTH,
-rick-

Hi Rick,
Thanks for the help. I had previously worked with VFP and in that this
was possible, So I never had a thought this will end up in a infinite
recursion.
 
Back
Top