none
The type 'System.Windows.Forms.Form' has no property named 'DataGridView1'. RRS feed

  • Question

  • Hi Team,

    I am facing one issue. I had got project from one of our clients that's developed in C# Windows Application. But it's not able to run it's giving errors.

    The type 'System.Windows.Forms.Form' has no property named 'DataGridView1'.

    In the code there is already a property named.

       [AccessedThroughProperty("DataGridView1")]
        private DataGridView _DataGridView1;
    
    
    
      internal virtual DataGridView DataGridView1
        {
          get
          {
            return this._DataGridView1;
          }
          [MethodImpl(MethodImplOptions.Synchronized)] set
          {
            DataGridViewCellEventHandler cellEventHandler = new DataGridViewCellEventHandler(this.DataGridView1_CellContentClick);
            if (this._DataGridView1 != null)
              this._DataGridView1.CellContentClick -= cellEventHandler;
            this._DataGridView1 = value;
            if (this._DataGridView1 == null)
              return;
            this._DataGridView1.CellContentClick += cellEventHandler;
          }
        }
    

    Please let me know how i can fix the error.

    Thanks

    J


    Jaspreet Singh

    Saturday, September 17, 2016 1:38 PM

All replies

  • Hi Jaspreet,

    >>"In the code there is already a property named."

    Have you built your project? Are there any build errors in Error List Window?

    Best Regards,
    Li Wang


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, September 19, 2016 6:48 AM
  • Hi Li Wang,

    There are no build errors. Project is building successfully.

    Thanks

    J


    Jaspreet Singh

    Monday, September 19, 2016 1:14 PM
  • Hi Li Wang,

    I have hosted the solution that's developed in C# Windows Application on below link:

    http://www.filehosting.org/file/details/602721/ProjectSolution.zip

    Thanks


    Jaspreet Singh

    Monday, September 19, 2016 4:15 PM
  • There is not file found at that location. Please post the solution here.
    Monday, May 20, 2019 10:58 AM
  • The problem is that the forms designer does not like these parts of your form:

             private System.Windows.Forms.TextBox withEventsField_TextBox19;
            internal System.Windows.Forms.TextBox TextBox19 {
                get { return withEventsField_TextBox19; }
                set {
                    if (withEventsField_TextBox19 != null) {
                        withEventsField_TextBox19.TextChanged -= TextBox19_TextChanged;
                    }
                    withEventsField_TextBox19 = value;
                    if (withEventsField_TextBox19 != null) {
                        withEventsField_TextBox19.TextChanged += TextBox19_TextChanged;
                    }
                }
            }

    The conversion from VB.NET WithEvents has produced this code in C# but the forms designer expects TextBox19 to be a field and not a property.

    You will probably have to convert the above code to:

    private System.Windows.Forms.TextBox TextBox19;

    And then you will need to update the form so the events fired by the controls are caught by the handler methods. You can either do this by hand or by opening the form in the forms designer and then picking the correct event handler method (e.g. TextBox19_TextChanged) for the required event.

    Monday, October 7, 2019 11:32 PM