473,505 Members | 13,805 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Automating Late Binding Object to a Control

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
Jul 21 '05 #1
6 1779
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.

Jul 21 '05 #2
Thanks for the update Tim.
And yes it has been a good day!
Enjoy!

Steve
"Tian Min Huang" <ti******@online.microsoft.com> wrote in message
news:Pb**************@cpmsftngxa10.phx.gbl...
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.

Jul 21 '05 #3
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.
Jul 21 '05 #4
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
"Felix Lima [MSFT]" <fe****@online.microsoft.com> wrote in message
news:CD**********************************@microsof t.com...
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 String
Get
If objectref Is Nothing Then
objectref = New lgconnection
End If
Return objectref.objectname
End Get
Set(ByVal Value As String)
objectref.objectname = Value
End Set
End Property
Here's a full implementation sample for anyone interested:

Imports System.ComponentModel

Public Class UserControl1
Inherits System.Windows.Forms.UserControl

#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() call

End Sub

'UserControl1 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
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
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()
'
'UserControl1
'
Me.Name = "UserControl1"

End Sub

#End Region
Private objectref As lgconnection
<RefreshPropertiesAttribute(RefreshProperties.All) , _
Description("Name of Object."), _
Category("Misc")> _
Public Property ObjectName() As String
Get
If objectref Is Nothing Then
objectref = New lgconnection
End If

Return objectref.objectname

End Get
Set(ByVal Value As String)
objectref.objectname = Value
End Set
End Property
Public Interface myObjectType
Property objectname() As String
End Interface

Public Class lgconnection

Implements myObjectType
Private m_objectname As String

Public Property objectname() As String Implements myObjectType.objectname Get
Return m_objectname
End Get
Set(ByVal Value As String)
m_objectname = Value
End Set
End Property
End Class
End Class

HTH

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.

Jul 21 '05 #5
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.
Jul 21 '05 #6
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.

Jul 21 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
379
by: noone | last post by:
I like to write my code with optionstrict set to on, except for the late binding errors I get when there is a reason to change some value in a control on a postback, like: Label4.Text =...
0
289
by: runningdog | last post by:
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...
1
7914
by: JD Kronicz | last post by:
Hi .. I have an issue I have been beating my head against the wall on for some time. I am trying to use late binding for MS graph so that my end users don't have to worry about having the right...
7
3020
by: PC Datasheet | last post by:
I have this: Dim Cbr As Object Dim Ctl As Object Set Cbr = Application.Commandbars("CourseCalendarMonth") Set Ctl = Application.Commandbars("CourseCalendarMonth").Controls("CalendarMonth") Is...
9
10392
by: Zlatko Matiæ | last post by:
I was reading about late binding, but I'm not completely sure what is to be done in order to adjust code to late binding... For example, I'm not sure if this is correct: early binding: Dim ws...
2
6631
by: Mystery Man | last post by:
We are developing a C# application that has many interfaces to the Microsoft suite (eg Word, Excel, Outlook, Powerpoint, etc). We need to support Office 97, 2000, 2002 and any future versions. ...
22
15312
by: Howard Kaikow | last post by:
There's a significant problem in automating Excel from VB .NET. Reminds me of a problem I encountered almost 3 years ago that was caused by the Norton Auntie Virus Office plug-in. Can anybody...
5
2029
by: eBob.com | last post by:
In another thread VJ made me aware of Tag. Fantastic! I've been wanting this capability for a long time. But it seems that I cannot use it with Option Strict On. In an event handler I have ......
5
3305
by: Arno R | last post by:
Hi all, I need to get at specific (shared) agenda-data from MS outlook 2003. I need every day to get the scheduled 'appointments' for some rooms to Access. In Access I will show the...
3
16042
ADezii
by: ADezii | last post by:
The process of verifying that an Object exists and that a specified Property or Method is valid is called Binding. There are two times when this verification process can take place: during compile...
0
7213
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7098
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7298
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7366
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7471
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5026
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4698
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1526
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
406
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.