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

aferiaAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
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.

VBRocksCommented:
It's not persisted.  I think you'll need to set it at runtime (like when the form loads).
0
aferiaAuthor Commented:
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?
0
PaulHewsCommented:
You want to create a designer for your control:

ASP.NET Control Designers Overview
http://msdn.microsoft.com/en-us/library/wxh45wzs.aspx
0
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

aferiaAuthor Commented:
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?
0
PaulHewsCommented:
I may be off base.  Is this an ASP.NET custom control or for WinForms?
0
aferiaAuthor Commented:
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.
0
PaulHewsCommented:
Okay, sorry, I thought it was about an ASP.NET server control for some reason (My misreading the question zones.)

Here is code that persists changes made to the button in design time.  The key is the DesignerSerializationVisibility metadata attribute:  http://msdn.microsoft.com/en-us/library/system.componentmodel.designerserializationvisibilityattribute.aspx
Imports System.ComponentModel
 
 
Public Class UserControl1
    <Description("Config Button"), Category("CONFIG"), DesignerSerializationVisibility(DesignerSerializationVisibility.Content)> _
        Public Property ConfigButton() As Button
        Get
            Return Button1
        End Get
        Set(ByVal value As Button)
            Button1 = value
        End Set
    End Property
 
End Class

Open in new window

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
aferiaAuthor Commented:
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?
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
Visual Basic.NET

From novice to tech pro — start learning today.