using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;namespace WindowsApplication1
{
public partial class Form1 : Form
{
bool isPressed = false;
int px = 0;
int py = 0;
Color color = Color.Black;
public int size = 0;
public Form1()
{
InitializeComponent();
} private void Form1_MouseDown(object sender, MouseEventArgs e)
{
px = e.X;
py = e.Y;
isPressed = true;
} private void Form1_MouseMove(object sender, MouseEventArgs e)
{
if (isPressed)
{
int tempX = e.X;
int tempY = e.Y;
Graphics g = this.CreateGraphics();
g.DrawLine(new Pen(color, size),px,py,tempX,tempY);
px = tempX;
py = tempY;
}
} private void Form1_MouseUp(object sender, MouseEventArgs e)
{
isPressed = false;
} private void 画笔颜色ToolStripMenuItem_Click(object sender, EventArgs e)
{
ColorDialog dialog = new ColorDialog();
dialog.ShowDialog();
color = dialog.Color;
} private void 画笔粗细ToolStripMenuItem_Click(object sender, EventArgs e)
{
FrmSize frmSize = new FrmSize(this);
frmSize.ShowDialog();
} }
}
出现以下错误错误 1 类型“WindowsApplication1.Form1”已定义了一个名为“Form1”的具有相同参数类型的成员 E:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\WindowsApplication1\WindowsApplication1\Program.cs 18 17 WindowsApplication1
怎么解决,求高手指导
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;namespace WindowsApplication1
{
public partial class Form1 : Form
{
bool isPressed = false;
int px = 0;
int py = 0;
Color color = Color.Black;
public int size = 0;
public Form1()
{
InitializeComponent();
} private void Form1_MouseDown(object sender, MouseEventArgs e)
{
px = e.X;
py = e.Y;
isPressed = true;
} private void Form1_MouseMove(object sender, MouseEventArgs e)
{
if (isPressed)
{
int tempX = e.X;
int tempY = e.Y;
Graphics g = this.CreateGraphics();
g.DrawLine(new Pen(color, size),px,py,tempX,tempY);
px = tempX;
py = tempY;
}
} private void Form1_MouseUp(object sender, MouseEventArgs e)
{
isPressed = false;
} private void 画笔颜色ToolStripMenuItem_Click(object sender, EventArgs e)
{
ColorDialog dialog = new ColorDialog();
dialog.ShowDialog();
color = dialog.Color;
} private void 画笔粗细ToolStripMenuItem_Click(object sender, EventArgs e)
{
FrmSize frmSize = new FrmSize(this);
frmSize.ShowDialog();
} }
}
出现以下错误错误 1 类型“WindowsApplication1.Form1”已定义了一个名为“Form1”的具有相同参数类型的成员 E:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\WindowsApplication1\WindowsApplication1\Program.cs 18 17 WindowsApplication1
怎么解决,求高手指导
看起来这样:
partial class Form1
我以为你把它删掉了,sorry。
你搜一下有多少个Form1吧,看一下是不是前面都有Partial。
或者你有两个一样的Form都叫Form1?