contro with custom properties
-
how can i create a custom control with some properties i can see in property visual studio window when i use it inside a form?
You have to use fields, you cannot just make variables public: This will not work:
public int MyInteger=1;
This will:
private int myInteger=1;
public int MyInteger
{
get
{
return myInteger;
}
set
{
myInteger=value;
}
}If you want variables to be read only, just omit the set accessor:
private int myInteger=1;
public int MyInteger
{
get
{
return myInteger;
}
}You can adjust the visible attributes in the property designer:
private int myInteger=1;
[Description("A useless number."),Category("Behavior")]
public int MyInteger
{
get
{
return myInteger;
}
set
{
myInteger=value;
}
}Hope this helps, DigitalKing
-
You have to use fields, you cannot just make variables public: This will not work:
public int MyInteger=1;
This will:
private int myInteger=1;
public int MyInteger
{
get
{
return myInteger;
}
set
{
myInteger=value;
}
}If you want variables to be read only, just omit the set accessor:
private int myInteger=1;
public int MyInteger
{
get
{
return myInteger;
}
}You can adjust the visible attributes in the property designer:
private int myInteger=1;
[Description("A useless number."),Category("Behavior")]
public int MyInteger
{
get
{
return myInteger;
}
set
{
myInteger=value;
}
}Hope this helps, DigitalKing