Link to home
Start Free TrialLog in
Avatar of aferia
aferia

asked on

Building a composite custom control...

I have built a custom control that has a Button on it.
I have added a property in my control so that I can change the button in design mode. The problem is that any changes I make are not reflected once I run the program.
Imports System.ComponentModel
Public Class UserControl1
    <Description("Config Button"), Category("CONFIG")> _
    Public Property ConfigButton() As Button
        Get
            Return m_btnConfig
        End Get
        Set(ByVal value As Button)
            m_btnConfig = value
        End Set
    End Property
End Class

Open in new window

Avatar of VBRocks
VBRocks
Flag of United States of America image

It's not persisted.  I think you'll need to set it at runtime (like when the form loads).
Avatar of aferia
aferia

ASKER

That is what I wa afraid of. I really needed to be able to change the button in design mode. I was thinking of having a several properties connected directly to the buttons members (ie: button.Text, button.Visible, etc). That seems to work fine, but it is just not ideal. Is there really no way to make the information persist from design to run-time?
You want to create a designer for your control:

ASP.NET Control Designers Overview
http://msdn.microsoft.com/en-us/library/wxh45wzs.aspx
Avatar of aferia

ASKER

There is a lot of information in the link you have given. I have been looking over it, but I have not found anything that applies for what I need. Is there a place with code samples or a tutorial on how to do the specific thing that I am trying to?
I may be off base.  Is this an ASP.NET custom control or for WinForms?
Avatar of aferia

ASKER

I'm actually trying to create a custom control to be used with Forms in a Visual Basic .NET aplication... so WinForms. I have been researching for hours now and I cant find anything that explains what I am trying to do.
ASKER CERTIFIED SOLUTION
Avatar of PaulHews
PaulHews
Flag of Canada image

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
Avatar of aferia

ASKER

That was exactly what I was looking for. Thanks so much! But I have another issue with a DataGridView though, when I try setting the "Columns" it gives me the null reference error. Do you know why?