Automating Late Binding Object to a Control

  • Thread starter Thread starter runningdog
  • Start date Start date
R

runningdog

Hi,

I have a Windows Form Control that needs to interact with an object created by the project consuming the control. So I have exposed a Public property which I can set to the name of the object at design time.
eg.

Class MyControl
....
Private ObjectRef As lgeConnection.lgeConnection

<RefreshPropertiesAttribute(RefreshProperties.All), _
Description("Name of Object."), _
Category("Misc")> _
Public Property ObjectName() As MyObjectType
Get
Return ObjectRef
End Get
Set(ByVal Value As MyObjectType)
ObjectRef = Value
End Set
End Property
...
End Class

Question: Can I get the designer to find an instance of MyObjectType and set ObjectName at design time. There should always be one and only one instance of this class.

TIA
Steve
 
Hello Steve,

Thanks for your post. Currently I am looking for appropriate resource to
help you with this issue.

Have a nice day!

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Hey Steve

If I have understood your question correctly, the problem is that your
ObjectName property is returning MyObjectType instead of a String which is
what you need

e.g.

<RefreshPropertiesAttribute(RefreshProperties.All),
Description("Name of Object."),
Category("Misc")>
Public Property ObjectName() As Strin
Ge
If objectref Is Nothing The
objectref = New lgconnectio
End I
Return objectref.objectnam
End Ge
Set(ByVal Value As String
objectref.objectname = Valu
End Se
End Propert

Here's a full implementation sample for anyone interested

Imports System.ComponentMode

Public Class UserControl
Inherits System.Windows.Forms.UserContro

#Region " Windows Form Designer generated code

Public Sub New(
MyBase.New(

'This call is required by the Windows Form Designer
InitializeComponent(

'Add any initialization after the InitializeComponent() cal

End Su

'UserControl1 overrides dispose to clean up the component list
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean
If disposing The
If Not (components Is Nothing) The
components.Dispose(
End I
End I
MyBase.Dispose(disposing
End Su

'Required by the Windows Form Designe
Private components As System.ComponentModel.IContaine

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

'UserControl

Me.Name = "UserControl1

End Su

#End Regio

Private objectref As lgconnectio

<RefreshPropertiesAttribute(RefreshProperties.All),
Description("Name of Object."),
Category("Misc")>
Public Property ObjectName() As Strin
Ge
If objectref Is Nothing The
objectref = New lgconnectio
End I

Return objectref.objectnam

End Ge
Set(ByVal Value As String
objectref.objectname = Valu
End Se
End Propert

Public Interface myObjectTyp
Property objectname() As Strin
End Interfac

Public Class lgconnectio

Implements myObjectTyp
Private m_objectname As Strin

Public Property objectname() As String Implements myObjectType.objectnam
Ge
Return m_objectnam
End Ge
Set(ByVal Value As String
m_objectname = Valu
End Se
End Propert
End Clas

End Clas

HT

Félix Lim
Visual Basic and Visual Basic .NE

This posting is provided "AS IS" with no warranties, and confers no rights
Please reply to newsgroups only.
 
Hi Felix,

I'm not sure that my description was clear.
My code appears to function and I when I add an object of MyObjectType I can
set the property in the designer but I would like to automate this step.
Similar to the way that adding multiple sqlDataAdapters auotmatically bind
to a single sqlConnection.

Thanks Steve
 
Hey Steve,

I still don't understand what you mean. Can you post your full code (both
the usercontrol and a consuming winform app) and provide some more detail
of what you are trying to accomplish?

Thanks,

Félix Lima
Visual Basic and Visual Basic .NET


This posting is provided "AS IS" with no warranties, and confers no rights.
Please reply to newsgroups only.
 
Hey Steve,

I still don't understand what you mean. Can you post your full code (both
the usercontrol and a consuming winform app) and provide some more detail
of what you are trying to accomplish?

Thanks,

Félix Lima
Visual Basic and Visual Basic .NET


This posting is provided "AS IS" with no warranties, and confers no rights.
Please reply to newsgroups only.
 
Back
Top