1

Something happens strange... I have a Receipt.cs class in my project. When i try to bound my datagridview to this class then there is no option of Receipt.cs in Choose Data Source Option.

In my previous project everything works well in visual studio. I couldn't understand why this happens in my new project.

Here is Image, No option for Receipt.cs But my project has Receipt.cs Class

Here is my Receipt.cs Class.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Store_Management_System
{
    public class Receipt
    {
        public int Id { get; set; }
        public string ProductName { get; set; }
        public double Price { get; set; }
        public int Quantity { get; set; }
        public string Total { get { return string.Format("{0}$", Price *  Quantity);  } }
    }
}

References in my Project. May be i am missing some reference?

Umair Mahmood
  • 63
  • 1
  • 9

3 Answers3

2

After creating Receipt.cs class, I rebuild the project but build was not successful as there is some little error (But not in Receipt.cs class).

I removed the error and make Successful Build, Then everything goes Fine...!!!

Umair Mahmood
  • 63
  • 1
  • 9
1

The Class should appear in Object Data Source List after its being compiled. It looks you have not recompiled/build the project containing the Receipt class.

-Thanks

Munawar
  • 2,588
  • 2
  • 26
  • 29
0

this was left unsolved by people. I just want to share the solution to this.

  1. Go to the properties of the datagridview and click on the databindings property.
  2. Choose (Advanced) and click on the ellipses.
  3. Click on the Binding combo box then
  4. Click on the "Add Project Data Source.
  5. Choose the Object and click on "Next".
  6. Then expand your program and choose the class you created.
  7. Click on "Finish" then "OK" button.
  8. Now click on the small triangle button on the datagridview and hit on the combo box again and see the "Other Data Sources..."
Mahyar Mottaghi Zadeh
  • 1,178
  • 6
  • 18
  • 31