wyrd
Senior Contributor
Question about how I can do GUI programming with an OO approach..
Say you've got a couple of tab pages, and within each tab page are some controls and whatever else you may have there. Obviously, the form in which all these reside would have a huge code page (all those events and helper methods that access controls on the form).
How can I logically break the different tab pages into classes so I can still easily access the child controls that are on the tab pages? ATM I've been breaking the code up using #region, but still, that just doesn't seem right. Anything methods that I can make generic enough and group them in a logical form are encapsulated into classes, unfortunately the problem comes with dealing with the GUI interface itself.
I'm not sure of a better way to explain this. Let me try this;
There's a tab control with two tab pages, and each tab page has a list view and text boxes and buttons on it. I want to encapsulate each tab pages functionality into a class. By this, I mean, I want a class that will accept what tab page it's using and be able to use all child controls within it, and when the user for example clicks a button (a child control on the tab page), it will trigger the event inside the class which is encapsulating the tab page.
Does this make sense? Obviously keeping all events, etc in the main forms code page for ALL controls on it (which could be a lot) seems to just be a bad idea to me, especially if it's a large program. I'm looking for a logical way to organize the code in an OOP way.
Thanks for the help, and hopefully I'm not confusing anyone but myself.
Say you've got a couple of tab pages, and within each tab page are some controls and whatever else you may have there. Obviously, the form in which all these reside would have a huge code page (all those events and helper methods that access controls on the form).
How can I logically break the different tab pages into classes so I can still easily access the child controls that are on the tab pages? ATM I've been breaking the code up using #region, but still, that just doesn't seem right. Anything methods that I can make generic enough and group them in a logical form are encapsulated into classes, unfortunately the problem comes with dealing with the GUI interface itself.
I'm not sure of a better way to explain this. Let me try this;
There's a tab control with two tab pages, and each tab page has a list view and text boxes and buttons on it. I want to encapsulate each tab pages functionality into a class. By this, I mean, I want a class that will accept what tab page it's using and be able to use all child controls within it, and when the user for example clicks a button (a child control on the tab page), it will trigger the event inside the class which is encapsulating the tab page.
Does this make sense? Obviously keeping all events, etc in the main forms code page for ALL controls on it (which could be a lot) seems to just be a bad idea to me, especially if it's a large program. I'm looking for a logical way to organize the code in an OOP way.
Thanks for the help, and hopefully I'm not confusing anyone but myself.