Syntax Error on Custom Control Attribute?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,

Thanks for reviewing my question. I am just starting out create a custom
control following the KB example "Create a Data Bound ListView Control". I
am receiving a syntax error on the following:

(43): No overload for method 'EditorAttribute' takes '1' arguments
(43): No overload for method 'GetType' takes '1' arguments

[Category("Data"),
EditorAttribute("System.Windows.Forms.Design.DataMemberListEditor,System.Design", GetType("System.Drawing.Design.UITypeEditor"))] // << SYNTAX ERROR
public string DataMember
{
get
{
return mDataMember;
}
set
{
mDataMember = value;
DataBind();
}
}

From the article, I need the attributes in order for VS.NET invoke a
specific object to manage the enhanced display in the Properties window.

Any ideas what causing the syntax error?

Many Thanks
Peter
 
Peter said:
Thanks for reviewing my question. I am just starting out create a custom
control following the KB example "Create a Data Bound ListView Control". I
am receiving a syntax error on the following:

(43): No overload for method 'EditorAttribute' takes '1' arguments
(43): No overload for method 'GetType' takes '1' arguments

[Category("Data"),
EditorAttribute("System.Windows.Forms.Design.DataMemberListEditor,
System.Design", GetType("System.Drawing.Design.UITypeEditor"))]
// << SYNTAX ERROR
public string DataMember
{
get
{
return mDataMember;
}
set
{
mDataMember = value;
DataBind();
}
}

From the article, I need the attributes in order for VS.NET invoke a
specific object to manage the enhanced display in the Properties window.

Any ideas what causing the syntax error?

The first is because of the second. You actually meant Type.GetType,
but you can't use that in an attribute declaration. Instead, you've got
to either use typeof, or just give the name as another parameter:

EditorAttribute ("...", "System.Drawing....")
or
EditorAttribute ("...", typeof(System.Drawing...));
or even
EditorAttribute (typeof(System.Windows...), typeof(System.Drawing...));
 
You might want to prefix GetType with its namespace Type like so....

[Category("Data"),

EditorAttribute("System.Windows.Forms.Design.DataMemberListEditor,System.Des
ign", Type.GetType("System.Drawing.Design.UITypeEditor"))]

or add the System.Type namespace to your file.

-Azhagan

Peter said:
Hello,

Thanks for reviewing my question. I am just starting out create a custom
control following the KB example "Create a Data Bound ListView Control". I
am receiving a syntax error on the following:

(43): No overload for method 'EditorAttribute' takes '1' arguments
(43): No overload for method 'GetType' takes '1' arguments

[Category("Data"),
EditorAttribute("System.Windows.Forms.Design.DataMemberListEditor,System.Des
ign", GetType("System.Drawing.Design.UITypeEditor"))] // << SYNTAX ERROR
 
Azhagan said:
You might want to prefix GetType with its namespace Type like so....

[Category("Data"),

EditorAttribute("System.Windows.Forms.Design.DataMemberListEditor,System.Des
ign", Type.GetType("System.Drawing.Design.UITypeEditor"))]

or add the System.Type namespace to your file.

There's no namespace System.Type. Type is the *classname*. Not that you
can call methods in attribute declarations.
 
Thanks, Jon. I stand corrected... there is no namespace called Type.

Jon Skeet said:
Azhagan said:
You might want to prefix GetType with its namespace Type like so....

[Category("Data"),

EditorAttribute("System.Windows.Forms.Design.DataMemberListEditor,System.Des
ign", Type.GetType("System.Drawing.Design.UITypeEditor"))]

or add the System.Type namespace to your file.

There's no namespace System.Type. Type is the *classname*. Not that you
can call methods in attribute declarations.
 
Back
Top