Scott Stewart

Scott Stewart

  • 1.6k
  • 189
  • 18k

Connecting a class to a form

Mar 5 2012 4:50 PM
This may belong in the C# forum, but I thought it goes here. I have a class with a couple of methods and several properties that match the form on which the user enters data. This class ("Document") represents a document that is in a database or a new document created by the user. The class will be added to a collection when it is created for a new document or from a record in the database. The question is I have a form created and I have a class created, but is there some way to tell the program that the two are related and somehow automatically populate the properties based on the data entry or the data read from the DB? I hope I made this clear. I see it in my head, but not knowing the .NET very well I am not sure if I am making what I want clearly enough for a real response. As I understand what I should do, is put the real work in the class and use the form as a vehicle to load the class. Once I have a collection I can do all sorts of things with all or each of the items.

Document Form data entry = 1 Document
Data read from database = 1 Document
Several Related Documents = 1 Collection
Do things with the Collection including display the data from a document in the same form as the data entry.

I really appreciate your input. If I have not been clear enough I will gladly answer any questions. I do something similar to this in Access 2010 using VBA. But I lost track of my programming and it is a kluge. I have the class there too, but I don't use it properly and I am constantly reading and writing to the DB. This covers changes to the data just fine, but it just isn't as clean as I wanted.

Answers (4)