Creating classes with non-visual components

Hi,

Is there any easy way of creating classes and "dropping" non-visual components (especially dataadapters, datasets etc) within this class.

I am aware we can hand-code these within the class but this is supposed to be object (component) based RAD - isnt it?

Thanks.

James.
JAMESAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

123654789987Commented:
If u can create a Form and then click ToolBox. Right click on Toolbox and then select "All tabs" . u have a option there data. Under that u will find DataAdapter and Datasets. U select one of them and drop them on to the form. This will create a an instance of them.
0
JAMESAuthor Commented:
Hmmm thanks but...

Perhaps I didnt explain the question properly.  We already use the Dataadapters etc in many places but it doesnt seem possible when you are creating a class as it will only allow a text view and the component tabs (including the non-visual ones) are then not available to the developer!

James.
0
msdixonCommented:
you need to create a "Component Class" not a class. This adds the necessary code in the "Windows Generated Code" (or something like that) region. it consists of an Initialize method, and a way to dispose of the objects.

in your project, hit Ctrl + Shift + A to add a new item (or if you're a mouse slave, click File | Add New Item), select "Component Class". Type your file name and hit enter.

add your code, and drag & drop components on it.
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

JAMESAuthor Commented:
msdixon,

Isnt the component class a framework for generating "new" components ?
0
msdixonCommented:
yes it is. to modify your existing class you'll have to take a look at the new class generated with the wizard and add the appropriate code. i don't remember off the top of my head what it is.
0
JAMESAuthor Commented:
Am I right in saying this is a "work around"?

Will check and report back - thanks so far...
0
msdixonCommented:
"Give a man a fish, and feed him for a day. Teach a man to fish and feed him for a lifetime"

here's your fish:

;-)

// remember to replace "[myClass]" with the actual class name
// class declaration
// inherit from Component
      public class [myClass] : System.ComponentModel.Component


// modify your constructor
            public [myClass](System.ComponentModel.IContainer container)
            {
                  ///
                  /// Required for Windows.Forms Class Composition Designer support
                  ///
                  container.Add(this);
                  InitializeComponent();

                  //
                  // TODO: Add any constructor code after InitializeComponent call
                  //
            }

            public [myClass]()
            {
                  ///
                  /// Required for Windows.Forms Class Composition Designer support
                  ///
                  InitializeComponent();

                  //
                  // TODO: Add any constructor code after InitializeComponent call
                  //
            }

// add this code to your class

      #region windows stuff...

      /// <summary>
      /// Required designer variable.
      /// </summary>
      private System.ComponentModel.Container components = null;

            /// <summary>
            /// Clean up any resources being used.
            /// </summary>
            protected override void Dispose( bool disposing )
            {
                  if( disposing )
                  {
                        if(components != null)
                        {
                              components.Dispose();
                        }
                  }
                  base.Dispose( disposing );
            }


            #region Component Designer generated code
            /// <summary>
            /// Required method for Designer support - do not modify
            /// the contents of this method with the code editor.
            /// </summary>
            private void InitializeComponent()
            {
                  components = new System.ComponentModel.Container();
            }
            #endregion

      #endregion
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
JAMESAuthor Commented:
Thanks.

Fisherman James.
0
msdixonCommented:
glad you thought it was funny... and glad i could help.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.