Error message - Coding Error

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lenniekuah
    New Member
    • Oct 2006
    • 126

    #1

    Error message - Coding Error

    Hi Good Guys,
    I need your help again. Please help me.
    While compiling my former Developer C# 2008 program I encounter these error messages.

    One of the error message is About DELEGATE. I have not heard of this before.


    Error message:

    Error 2'CShartNet2008 GeneralApps.Frm DataGrid' does not contain a definition for 'btnExportXML_C lick' and no extension method 'btnExportXML_C lick' accepting a first argument of type 'CShartNet2008G eneralApps.FrmD ataGrid' could be found (are you missing a using directive or an assembly reference?)

    Coding from File Name: FrmDataGridDesi gner.cs
    Code:
    this.btnExportXML.Font = new System.Drawing.Font("Verdana", 9F,       System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
                this.btnExportXML.Location = new System.Drawing.Point(472, -2);
                this.btnExportXML.Name = "btnExportXML";
                this.btnExportXML.Size = new System.Drawing.Size(119, 24);
                this.btnExportXML.TabIndex = 4;
                this.btnExportXML.Text = "Export XML File";
                this.btnExportXML.UseVisualStyleBackColor = true;
                this.btnExportXML.Click += new System.EventHandler(this.btnExportXML_Click);
    --------------------------------------

    Another error message


    Error 13 Expected class, delegate, enum, interface, or struct

    Coding from File Name : FrmDataGrid.cs
    Code:
      private void btnExportXML_Click(object sender, EventArgs e); handles BtnExportXML.Click
            {
    
            }
  • ZiadElmalki
    New Member
    • Sep 2010
    • 43

    #2
    The first error is complaining because it cannot find btnExportXML_Cl ick.

    The other error is because btnExportXML_Cl ick has the incorrect syntax and might not be nested inside a class. The stuff in bold is incorrect. There might be other errors else where in your code besides this. Post more if you need more help

    private void btnExportXML_Cl ick(object sender, EventArgs e); handles BtnExportXML.Cl ick
    {

    }

    Comment

    • Plater
      Recognized Expert Expert
      • Apr 2007
      • 7872

      #3
      Yeah, check to make sure the namespaces match and that the function is either defined in the same class (since it is private) or in the 'partial' class.

      However, in cases like these.... I find it is just better to delete that code and remake it. Wipe it out and crate a new event handler then copy/paste the functional code into the handler

      Comment

      • lenniekuah
        New Member
        • Oct 2006
        • 126

        #4
        Hi ZiadElmalki and Plater,
        Thanks to both of you for providing BEST ANSWER to my problem to dealing with the error message.

        Comment

        Working...