473,569 Members | 2,557 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.l geConnection

<RefreshPropert iesAttribute(Re freshProperties .All), _
Description("Na me 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 1797
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******@onlin e.microsoft.com > wrote in message
news:Pb******** ******@cpmsftng xa10.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.

<RefreshPropert iesAttribute(Re freshProperties .All),
Description("Na me of Object."),
Category("Misc" )>
Public Property ObjectName() As Strin
Ge
If objectref Is Nothing The
objectref = New lgconnectio
End I
Return objectref.objec tnam
End Ge
Set(ByVal Value As String
objectref.objec tname = Valu
End Se
End Propert

Here's a full implementation sample for anyone interested

Imports System.Componen tMode

Public Class UserControl
Inherits System.Windows. Forms.UserContr o

#Region " Windows Form Designer generated code

Public Sub New(
MyBase.New(

'This call is required by the Windows Form Designer
InitializeCompo nent(

'Add any initialization after the InitializeCompo nent() 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.Disp ose(
End I
End I
MyBase.Dispose( disposing
End Su

'Required by the Windows Form Designe
Private components As System.Componen tModel.IContain e

'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.Diagnos tics.DebuggerSt epThrough()> Private Sub
InitializeCompo nent(

'UserControl

Me.Name = "UserContro l1

End Su

#End Regio

Private objectref As lgconnectio

<RefreshPropert iesAttribute(Re freshProperties .All),
Description("Na me of Object."),
Category("Misc" )>
Public Property ObjectName() As Strin
Ge
If objectref Is Nothing The
objectref = New lgconnectio
End I

Return objectref.objec tnam

End Ge
Set(ByVal Value As String
objectref.objec tname = 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.ob jectnam
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******** *************** ***********@mic rosoft.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.:

<RefreshPropert iesAttribute(Re freshProperties .All), _
Description("Na me of Object."), _
Category("Misc" )> _
Public Property ObjectName() As String
Get
If objectref Is Nothing Then
objectref = New lgconnection
End If
Return objectref.objec tname
End Get
Set(ByVal Value As String)
objectref.objec tname = Value
End Set
End Property
Here's a full implementation sample for anyone interested:

Imports System.Componen tModel

Public Class UserControl1
Inherits System.Windows. Forms.UserContr ol

#Region " Windows Form Designer generated code "

Public Sub New()
MyBase.New()

'This call is required by the Windows Form Designer.
InitializeCompo nent()

'Add any initialization after the InitializeCompo nent() 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.Disp ose()
End If
End If
MyBase.Dispose( disposing)
End Sub

'Required by the Windows Form Designer
Private components As System.Componen tModel.IContain er

'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.Diagnos tics.DebuggerSt epThrough()> Private Sub
InitializeCompo nent()
'
'UserControl1
'
Me.Name = "UserContro l1"

End Sub

#End Region
Private objectref As lgconnection
<RefreshPropert iesAttribute(Re freshProperties .All), _
Description("Na me of Object."), _
Category("Misc" )> _
Public Property ObjectName() As String
Get
If objectref Is Nothing Then
objectref = New lgconnection
End If

Return objectref.objec tname

End Get
Set(ByVal Value As String)
objectref.objec tname = 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.ob jectname 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 = (sender.CommandArgument).tostring HiddenCreative.Value = sender.CommandArgument that are in a onclick handler for a webform. Looking at the doc it looks...
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 at design time. eg. Class MyControl .... Private ObjectRef As lgeConnection.lgeConnection ...
1
7921
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 version of the MS Graph type library. Up until now I have been walking them through the process of setting the references to include their version...
7
3030
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 this considered late binding? If not, what needs changed? Thanks!
9
10404
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 As DAO.Workspace Dim db As DAO.Database Dim qdf As DAO.QueryDef Dim rs As DAO.Recordset
2
6634
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. Our first cut used early binding and worked fine with Office 2002. We then ran on a machine that had Office 2000 installed and it all turned to...
22
15323
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 reproduce the behavior described below? For this example, I am using Excel 2002 and VS .NET 2002 and VB 6. MSFT KB article 304661 gives a trivial...
5
2037
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 ... Private Sub chkbxSelI_Click(ByVal sender As Object, ByVal e As System.EventArgs) MsgBox("bingo for number " & sender.Tag.ToString) End Sub
5
3313
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 time-periods that the rooms are booked for that day. I know how to code all this in Access. I can show some testdata for 5 rooms quite nicely on a form. I...
3
16050
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 time (Early Binding) or run time (Late Binding). When you declare an Object Variable as a specific Data Type, you are using Early Binding so the...
0
7700
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7924
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8125
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7676
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7974
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5513
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5219
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
2114
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 we have to send another system
0
938
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.