473,386 Members | 1,796 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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 1762
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
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
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
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
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
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
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
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
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
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
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
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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
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
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...

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.