Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 197
  • Last Modified:

How do I integrate a user control with Visual Studio

I intend to write my own version of the Datagrid control that will display the rows using different colours for different rows, the colour for a row being dependent on the data the row contains.

My question is: once I have built this control, can I make it appear in Visual Studio's Toolbox? And if I drag an instance of my datagrid onto a new form will it look and behave like a normal datagrid? This is what I want to achieve.
  • 2
  • 2
1 Solution
yes, you can do it 2 ways. Just create a new usercontrol and replace the inherits part with something like, it will appear in the toolbox

Public Class mydatagrid
    Inherits System.Windows.Forms.DataGrid

#Region " Windows Form Designer generated code "

    Public Sub New()

        'This call is required by the Windows Form Designer.

        'Add any initialization after the InitializeComponent() call

    End Sub

    'UserControl overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
            End If
        End If
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        components = New System.ComponentModel.Container()
    End Sub

#End Region

End Class

or create a new class , that also inherits from datagrid compile it to a dll, and than just right click the toolbox and choose add remove items and browse to your dll
Once you have built your control, you can add it to the Toolbox by right-clicking the Toolbox and selecting "Add/Remove Items."  Select your component and click "OK."  Your component should then be available in the Toolbox.
kilgore666Author Commented:
Thanks guys. I will split the points between you. But now I realise that there is something else I don't know which means I don't have a solution yet. See http://www.experts-exchange.com/Programming/Programming_Languages/Dot_Net/VB_DOT_NET/Q_21390364.html
kilgore666Author Commented:
Damn - I have forgotten how to split points - it was my intention to give you each 250.

Ron, if you would like your 250 points then I am afraid you will have to remind me where I post the request to give you your points and what to say there.

Sorry for the agro
Hi kilgote666,

Don't worry about the points, I really don't care about them (It is not that I can buy anything with them :-)

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now