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.
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
It's not persisted. I think you'll need to set it at runtime (like when the form loads).
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
ASP.NET Control Designers Overview
http://msdn.microsoft.com/en-us/library/wxh45wzs.aspx
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?
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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?