两个按钮之间的歧义

时间:2019-06-21 11:57:47

标签: c# visual-studio winforms

我创建了一个新按钮,该按钮具有与另一个按钮相似的功能。因此,我复制并粘贴了先前按钮中的代码,并根据新按钮进行了更改。但是我遇到了类似错误-错误23

'UHFDemo.R2000UartDemo.btnConnectArduino(object,System.EventArgs)'和'UHFDemo.R2000UartDemo.btnConnectArduino'之间的歧义

// btnConnectRs232
//this.btnConnectRs232.Font = new System.Drawing.Font("Microsoft Sans 
Serif", 
7.8F);
this.btnConnectRs232.ForeColor = System.Drawing.Color.FromArgb(((int) 
(((byte) 
(0)))), ((int)(((byte)(13)))), ((int)(((byte)(51)))));
this.btnConnectRs232.Location = new System.Drawing.Point(6, 89);
this.btnConnectRs232.Name = "btnConnectRs232";
this.btnConnectRs232.Size = new System.Drawing.Size(90, 25);
this.btnConnectRs232.TabIndex = 2;
this.btnConnectRs232.Text = "Connect";
this.btnConnectRs232.UseVisualStyleBackColor = true;
this.btnConnectRs232.Click += new 
System.EventHandler(this.btnConnectRs232_Click);
// 
// btnConnectArduino
// 
this.btnConnectArduino.Font = new System.Drawing.Font("Microsoft Sans 
Serif", 
7.8F);
this.btnConnectArduino.ForeColor = System.Drawing.Color.FromArgb(((int) 
(((byte)(0)))), ((int)(((byte)(13)))), ((int)(((byte)(51)))));
this.btnConnectArduino.Location = new System.Drawing.Point(6, 89);
this.btnConnectArduino.Name = "btnConnectArduino";
this.btnConnectArduino.Size = new System.Drawing.Size(90, 25);
this.btnConnectArduino.TabIndex = 2;
this.btnConnectArduino.Text = "Connect";
this.btnConnectArduino.UseVisualStyleBackColor = true;
this.btnConnectArduino.Click += new 
System.EventHandler(this.btnConnectArduino_Click);
// 
private void btnConnectArduino(object sender, EventArgs e)
{
//Processing serial port to connect reader.
string strException = string.Empty;
string strComPort = cmbComPort.Text;
int nBaudrate = Convert.ToInt32(cmbBaudrate.Text);
int nRet = reader.OpenCom(strComPort, nBaudrate, out strException);
if (nRet != 0)
{string strLog = "Connection failed, failure cause: " + strException;
WriteLog(lrtxtLog, strLog, 1);
return;
}else
{
string strLog = "Connect" + strComPort + "@" + nBaudrate.ToString();
WriteLog(lrtxtLog, strLog, 0);
}
//Whether processing interface element is valid.
SetFormEnable(true);
btnConnectArduino.Enabled = false;
btnDisconnectRs232.Enabled = true;
//Set button font color.
btnConnectArduino.ForeColor = Color.Black;
btnDisconnectRs232.ForeColor = Color.Indigo;
SetButtonBold(btnConnectArduino);
SetButtonBold(btnDisconnectRs232);
}
private void cmbComPort_SelectedIndexChanged(object sender, EventArgs e)
{    
}

现在我什至看不到设计。请帮助我

1 个答案:

答案 0 :(得分:0)

您的歧义是由您的按钮名称与方法名称btnConnectArduino相同引起的。更改其中之一将解决您的问题。