Link to home
Start Free TrialLog in
Avatar of marcothy2
marcothy2Flag for United States of America

asked on

add custom controls within project code to toolbox

Hello,

I am writing software in VB.NET 2003 due to our customers only having framework 1.1 on their computers.  Upgrading their framework is not an option.  I have created (and successfully used) a couple inherited custom controls by including the .vb files for these controls in the same project.  This way the controls are compiled into the same EXE and do not require external DLL files.

My question is this:  Is there a way to make these controls appear in the toolbox without creating a separate control library?  In 2005, controls included in this way are automatically added to the toolbox.  It is beginning to be a real pain to have to drop the control that I inherited from onto the form and then edit the Form Designer code manually.

Thanks in advance.
Avatar of Marv-in
Marv-in

in 2003

you add a new item of user control
build your project
control should show in the toolbox in the My User Controls section
Avatar of marcothy2

ASKER

Marv-in,

I have tried this, but I am inheriting from existing controls.  Since I need the line "Inherits System.Windows.Forms.TextBox", I cannot use "Inherits System.Windows.Forms.UserControl".  The reason I made these controls is to add additional functionality to the standard controls.  I have included below the basic shell of my code.  The actual code has different names and has several subroutines for each control.

'###BEGIN CODE###

Imports System.Windows.Forms

Namespace CustomControls
    Public Class modifiedTextBox
        Inherits System.Windows.Forms.TextBox

        .

        .

        .

    End Class

    Public Class modifiedDataGrid
        Inherits Windows.Forms.DataGrid

        .

        .

        .

    End Class

End Namespace

'###END CODE###
I should probably clarify that this code is in a seperate .vb file in my project.  I have rebuilt the solution and checked through every tab on the toolbox.
ASKER CERTIFIED SOLUTION
Avatar of Marv-in
Marv-in

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Ok.  This does work as long as I click add user control and paste the code in.  Using this method only allows for one control in each .vb file and means that in every project I have to click add control and paste this code into a file for every control that I have.  I also cannot put the control within a namespace.

I just tested and it will not add it to the toolbox if i add this file to another project and rebuild that project.  This isn't a very practical solution as I would like to be able to add my custom controls file with all custom controls to any project and have them show up.  Do you know of any other way, short of creating a DLL, to get this to work?
since you are forced to use 2003 - this is the only way i know of.

the practical solution for reusing the contorls in different projects would be to create a dll

however if you must use 2003 and dont wnat to create a common dll - you can copy the vb files that house the control code to a common location and add an existing item to each of the projects. visual studio will warn you that changes are made in one project and ask you to reload the file. you can also add a folder to the solution to keep the files grouped
i agree that in general, the most practical way to do this would be to create a dll.  however, in this case it is not practical as i need to have a standalone exe (with the exception of the framework 1.1 dlls, already installed on their computers, of course).  It just seems mildly ridiculous to me that I should have to edit the form generator code manually...  then again, it has been fixed in 2005.

i am going to wait and see if anyone else knows of a way to do what i would like to do.  if no one does, i will accept your answer.