Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/301.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 参数中的标签控制_C#_Winforms_Label - Fatal编程技术网

C# 参数中的标签控制

C# 参数中的标签控制,c#,winforms,label,C#,Winforms,Label,我正在尝试发送按摩和更改标签的颜色 private void updateStatus(string massageText, Label label) { txtStatus.Text = massageText; label.BackColor = Color.Red; } 当我尝试应用这一点时 updateStatus("Level-1 Complete", Label1); updateStatus("Level-2 Complete", Label2); 它给出了

我正在尝试发送按摩和更改标签的颜色

private void updateStatus(string massageText, Label label)
{
    txtStatus.Text = massageText;
    label.BackColor = Color.Red;
 }
当我尝试应用这一点时

updateStatus("Level-1 Complete", Label1);
updateStatus("Level-2 Complete", Label2);
它给出了错误的

与“Taal.Form1.updateStatus(string,System.Windows.Forms.Label)”匹配的最佳重载方法具有一些无效参数D:\Taal\Taal\Form1.cs”


此代码中有什么错误?

请尝试,下面的方法可用于任何表单控件

private void updateStatus(string massageText, System.Windows.Forms.Control control)
{
    txtStatus.Text = massageText;
    control.BackColor = Color.Red;
 }

事实上,我的标签在状态栏上,所以在评论的帮助下,我改正了它。谢谢

private void updateStatus(string massageText,ToolStripLabel label)
        {
            txtStatus.Text = massageText;
            label.BackColor = Color.Red;


        }

什么是完全错误?为什么不发布整个异常消息?您忽略了最有趣的部分,其中说明了它期望的内容和发现的内容完整的错误消息是:与'Taal.Form1.updateStatus(string,System.Windows.Forms.Label)匹配的最佳重载方法'有一些无效参数D:\Taal\Taal\Form1。cs@Braheen您最好编辑您的问题,并将完整的错误消息放在其中,而不是放在注释中。@Braheen如果您将鼠标移动到
Label1
Label2
,您应该会看到一条工具提示消息。工具提示应该是
class-System.Windows.Forms.Label
或类似内容。