Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
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
Reply With Quote
  #2 (permalink)  
Old June 8th, 2011, 02:18 PM
Friend of Wrox
Points: 1,104, Level: 13
Points: 1,104, Level: 13 Points: 1,104, Level: 13 Points: 1,104, Level: 13
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2008
Location: Indianapolis, IN, USA.
Posts: 224
Thanks: 0
Thanked 30 Times in 29 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)
Reply With Quote
  #3 (permalink)  
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.
Reply With Quote
  #4 (permalink)  
Old June 8th, 2011, 03:16 PM
Friend of Wrox
Points: 1,104, Level: 13
Points: 1,104, Level: 13 Points: 1,104, Level: 13 Points: 1,104, Level: 13
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2008
Location: Indianapolis, IN, USA.
Posts: 224
Thanks: 0
Thanked 30 Times in 29 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)
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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 01:11 PM
Need help creating this Form with a backend Class iampedro ASP.NET 2.0 Basics 0 February 10th, 2007 04:26 PM
Creating a Class for multi projects ocarroll General .NET 6 December 4th, 2004 04:13 PM
creating a .dll from a .cs class vb_developer C# 1 October 27th, 2004 05:59 PM



All times are GMT -4. The time now is 03:02 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.