Nice to read a question that is seeking guidelines for learning, not just a request for code. You are on-track for a solution because you have already defined a clear and unambiguous object model, which is excellent.
For creating a collection in .NET, you have many choices: your choice is (almost) certainly going to be found in the two .NET libraries:
using System.Collections;
using System.Collections.Generic;
In my humble opinion, the key questions to ask yourself in choosing a Collection type are:
1. is the type of object I will store always the same type ? For this case, the answer would be "yes," I think.
2. does the collection I need have to be IEnumerable, from the beginning, in order for me to use the fancy tools that LINQ provides for all types of operations on collections ? [1]
a. do I need to be able to easily sort the collection objects ?
b. do I need fancy ways to find an object, or objects in the collection, to copy them to other objects, etc. ? [2]
3. given how many objects I need to store, and the cost of storage per item, am I constrained in my choice of collection types by quantity, or constrained by performance aspects of access time, and collection manipulation time ? Note: this type of consideration was much more important several years ago !
4. advanced: considerations of thread safety, communication between threads, or processes, serialization and de-serialization ?
A quick look at
some of your choices: ... assuming that 'Note' is the name of your class that 'embodies' the Note object:
in System.Collections:
1. use of an Array or Arraylist:
Note[] NoteArray = new Note[10];
ArrayList NoteArrayList = new ArrayList();
Suggest you study and, possibly, implement the other collection types found in System.Collections: Stack, Queue, SortedList, HashTable.
in System.Collections.Generic: Suggest you start with the basic Generic List, then study and/or implement use of a Generic Dictionary:
1. use of a simple generic collection:
List<Note> GenericNoteList = new List<Note>();
2. use of a dictionary: what if you wanted to quickly access a given Note by a matching string, perhaps the Note title:
Dictionary<string, Note> GenericNoteDictionary = new Dictionary<string, Note>();
And now ... at last ... a sample solution: tested in VS Studio 2010 Pro with .NET FrameWork 4.0 client target only:
private Form2 f2;
private Form3 f3;
private void Form1_Load(object sender, EventArgs e)
{
f2 = new Form2();
f3 = new Form3();
f2.f2Button.Click += new EventHandler(f2Button_Click);
f3.f3TextBox.TextChanged += new EventHandler(f3TextBox_TextChanged);
}
Left for you to implement are the f2Button_Click, and f3TextBox_TextChanged event handlers in Form1, and the implementation in Form2, and Form3, of the necessary public properties and their intialization.
After you get your collection strategy worked out and tested, perhaps consider adding some 'extras' to the Note style: date-time field for each Note ... date created ... date modified, and a choice of colors for the Note text and/or background ?
bon apetit, Bill
... edit #1: minor clean-up of some tags that got scrambled in the code-blocks ...
... edit #2: restore sample code accidentally deleted in edit #1; simplified it a bit ...
[1] yes, you can convert certain collection types to IEnumerable that are not IEnumerable to start with, but there is a "cost" to that conversion.
[2] this may sound a bit "abstract," but it's really practical: for example: in the future, do you want users of your Post-It type application to easily find all the Nodes of a certain color, or created between two dates ? Generic Collections which are IEnumerable make this relatively easy.