what am I doing wrong in the way I do my GUI implementation?
Hello
I'm trying to have a nice [but basic GUI] in my C# project.
Eventhough I think I'm able to understand the difference between static and non-static and between public, private, protected, internal and so on. I can't say that I 'm happy with the code I write. this too much OO has driven me a bit crazy.
for example, I have a mainForm class in mainForm.cs and class
procListViewDlg in processListViewDlg.cs.
now,
processListViewDlg has a protected internal System.Windows.Forms.ListView readyProcsListView;
in mainForm [where my program starts ] I somewhere call
if (dlgRes = DialogResult.OK)
procListViewDlg.readyProcsListView.Items.Add(item); [intellisense doesn't
propose me the readyProcsListView] why> and what can I do about it?
When I try to compile I get:
An object reference is required for the nonstatic field, method, or property 'Simulator.procListViewDlg.readyProcsListView'
I don't understand much, I only get the idea that I should make
readyProcsListeView static . When I do that I get:
Static member 'Simulator.procListViewDlg.readyProcsListView' cannot be accessed with an instance reference; qualify it with a type name instead
concerning to a code the designer wrote which is:
this.readyProcsListView = new System.Windows.Forms.ListView();
so I'm trapped. and I have a lot of SIMILAR PROBLEMS with the way I implement my GUI. There must a be a better way that I'm not aware of.
the only way I made it work [but that way I don't like it much but I have used it for other more easy code] is to make a global.cs where I keep in a class public static variables.
so I can in the end make it work, but Designer refuses then to show the
listview control, cause I'm commenting code the designer writes, and making in the end a total labyrinth for me to get lost the next day I come back to the same lines of code.
so
i) why readyProcesListeView doesn't get exposed as non-static public and/or non-static internal protected
ii) what is the bad idea in the way I implement things? I don't like the code I write, it reminds me VBasic stuff
I'm in a dead end, he who will help me must have 2 excellent weeks in a row after his help!