Wrox Programmer Forums
|
BOOK: Beginning C# 3.0 : An Introduction to Object Oriented Programming ISBN: 978-0-470-26129-3
This is the forum to discuss the Wrox book Beginning C# 3.0 : An Introduction to Object Oriented Programming by Jack Purdum; ISBN: 9780470261293
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning C# 3.0 : An Introduction to Object Oriented Programming ISBN: 978-0-470-26129-3 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 8th, 2011, 07:39 AM
Registered User
 
Join Date: Jun 2011
Posts: 4
Thanks: 1
Thanked 0 Times in 0 Posts
Default Creating a new groupbox through a class

Hi Guys

I need some help urgently. . . . I have my main form :Frmtest, now i went and added a class. What i want to do with that class is to add a groupbox on my form when i click on a button.

The problem that i have is that I cannot add the control in the class?

Can anyone help me?

Thanks
 
Old June 8th, 2011, 02:18 PM
Friend of Wrox
 
Join Date: Sep 2008
Posts: 234
Thanks: 0
Thanked 32 Times in 30 Posts
Default Add a groupbox from a class

As a general rule, I don't write classes that do any graphical or user interface (UI) work. The reason is because that limits the usefulness of the class because you've now hard-wired the name of some interface object to the code.

As a work-around, ask yourself if you really need the class to add a groupbox to a form. Chances are, you don't. For example, could you write a method in the class that toggles the groupbox's Visibility property from False to True? This means, of course, that the groupbox is always on the form...only its visibility changes. You could pass the Groupbox ID into the class and have the method set it there. This makes the class more flexible since you don't have to hard-code the name of the Groupbox into the class.

It's pretty hard for me to think of a good example where I need a class to do some kind of direct interface work. As a general rule, I try to keep all UI stuff outside of my classes, leaving the UI code as part of the form itself.
__________________
Jack Purdum, Ph.D.
Author: Beginning C# 3.0: Introduction to Object Oriented Programming (and 14 other programming texts)
 
Old June 8th, 2011, 02:54 PM
Registered User
 
Join Date: Jun 2011
Posts: 4
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Yes I understand but what i want to do is to create a groupbox with controls on and when a user selects a option the class generates a groupbox with the details on for that option.
 
Old June 8th, 2011, 03:16 PM
Friend of Wrox
 
Join Date: Sep 2008
Posts: 234
Thanks: 0
Thanked 32 Times in 30 Posts
Default Groupbox

I still don't see why you can't have several invisible groupboxes on the form and make the one they select visible from within the class.
__________________
Jack Purdum, Ph.D.
Author: Beginning C# 3.0: Introduction to Object Oriented Programming (and 14 other programming texts)





Similar Threads
Thread Thread Starter Forum Replies Last Post
creating variable in a class Ashmadia BOOK: Beginning ASP.NET 4 : in C# and VB 5 April 30th, 2011 02:06 PM
Uncheck in groupbox of radio buttons alkh C# 0 November 8th, 2008 02:11 PM
Need help creating this Form with a backend Class iampedro ASP.NET 2.0 Basics 0 February 10th, 2007 05:26 PM
Creating a Class for multi projects ocarroll General .NET 6 December 4th, 2004 05:13 PM
creating a .dll from a .cs class vb_developer C# 1 October 27th, 2004 05:59 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.