dcsimg
Results 1 to 6 of 6

Thread: How do i make a control that doesnt go on a form?

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Nov 2016
    Location
    UK
    Posts
    21

    How do i make a control that doesnt go on a form?

    when you add an image list or a timer control they don't appear on the main form, instead they get put into an area beneath the form. How is that done?

  2. #2
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    99,409

    Re: How do i make a control that doesnt go on a form?

    That's because they are not controls. Did you think to read the documentation for those classes? Doing so for either would have shown you that they both inherit the System.ComponentModel.Component class. That is what makes a type able to be designed. The System.Windows.Forms.Control class, which is the base class for all controls, itself inherits the System.ComponentModel.Component, so a control is a specialised component.

    If you check the Project menu for a Windows Forms project, you'll see that Add Component is one of the primary options. Using that will add a class that inherits Component and provides a design surface as well as code, much like a form. It's just that what you do on the design surface won't be visible in the UI. It's much like the component tray you see at the bottom of the form design window.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    99,409

    Re: How do i make a control that doesnt go on a form?

    For an example of a component built from scratch, check this out:

    http://www.vbforums.com/showthread.p...rays-in-VB-NET

    In that particular case, I used the Class item template rather than the Component item template and then just added the Inherits line myself. You can do that if you don't intend to use the designer at all. If I had used the Component item template then, just like for a form, there would have been two code files - one for designer and one for user - and the Inherits line would have been in the designer code file.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Nov 2016
    Location
    UK
    Posts
    21

    Re: How do i make a control that doesnt go on a form?

    Very much appreciated info jmcilhinney, thank you. Do you always have to make a person feel bad before you attempt to help them?
    Last edited by LucasCain; Aug 12th, 2018 at 04:13 AM.

  5. #5
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    99,409

    Re: How do i make a control that doesnt go on a form?

    Quote Originally Posted by LucasCain View Post
    Do you always have to make a person feel bad before you attempt to help them?
    My point of view is that if someone hands you the answer every time then that will encourage you to ask the question every time, whereas if someone gives you reason to think about doing what you can for yourself then you're far more likely to do that. I'm absolutely in favour of people using forums - I've asked questions here myself - but only after doing what they can for themselves first. That's not necessarily banging your head against a brick wall for days but reading the documentation is not an onerous task so everyone should be doing that at least. If anyone should be using the Help menu in a software application, it's software developers. I think that learning how to find information for yourself is critical to becoming the best developer you can be. If people are more likely to do that if they want to avoid a caustic remark from me then I'll provide that caustic remark. The best way to avoid those remarks is to do what you can for yourself first and only ask questions here when you can't find what you need or can't understand what you find. There are plenty of such questions on this site that I've replied to without a caustic remark.
    Last edited by jmcilhinney; Aug 12th, 2018 at 07:04 PM.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  6. #6
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    21,793

    Re: How do i make a control that doesnt go on a form?

    Quote Originally Posted by jmcilhinney View Post
    My point of view is that if someone hands you the answer every time then that will encourage you to ask the question every time, whereas if someone gives you reason to think about doing what you can for yourself then you're far more likely to do that.
    You're lucky to get a thankyou. I rarely do these days

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width