1
目前,我对Visual Studio中的Windows窗体应用程序,但每次我试着画出一个形状或符合油漆事件中,我得到这个错误:Paint事件的Visual Studio
C2228: “.DrawString”的左边必须有类/结构/联合
下面是我的代码,包括从头文件中的痛苦事件:
using namespace System::Drawing;
void InitializeComponent(void)
{
this->Paint += gcnew System::Windows::Forms::PaintEventHandler(this, &Form1::Form1_Paint);
}
{
private: System::Void Form1_Paint(System::Object^ sender, System::Windows::Forms::PaintEventArgs^ e) {
e.Graphics.DrawRectangle(blackPen, x, y, width, height);
}
};
任何帮助将不胜感激
你不是在代码片段调用'DrawString'。 –
您需要学习正确的C++/CLI语法,它不是C#。 PaintEventArgs和Graphics是引用类型,您可以使用 - >箭头来引用它们的成员。 –