Syntax Error on Custom Control Attribute?

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
 
J

Jon Skeet [C# MVP]

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...));
 
A

Azhagan

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
 
J

Jon Skeet [C# MVP]

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.
 
A

Azhagan

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top