I'm not 100% sure how this would help me..
If I exposed all my properties of my class using this method, how would this
help me to bind a text box for example to a property of a specific instance
of this class in the designer???
Or have I totally misunderstood you ??
Thanks in advance!
Simon
"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in message
news:%23NPtaWuWEHA.1104@TK2MSFTNGP10.phx.gbl...[color=blue]
> If you want to set a wrapped control's custom property from the designer[/color]
you[color=blue]
> need to add attribute tags. When its added to the form you will see the
> custom property, is this what you need ?
>
> IE
> <Browsable(True), Category("Appearance")> _
>
> Public Property xxxxx as xxxxxxxx
>
> .
>
> .
>
> .
>
>
> --
>
> OHM ( Terry Burns )
> . . . One-Handed-Man . . .
>
> Time flies when you don't know what you're doing
>
> "Simon Verona" <news@aphroditeuk.com> wrote in message
> news:uZBxnctWEHA.3716@TK2MSFTNGP11.phx.gbl...[color=green]
> > Could I perhaps then inherit the textbox and add fields for the "object
> > name" and property to map to and then get the object using reflection to[/color]
> do[color=green]
> > the mapping in code from within the inherited control?? Or am I being[/color][/color]
too[color=blue][color=green]
> > ambitious????
> >
> >
> > Thanks for all your help so far.
> >
> > Simon
> > "One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in[/color]
> message[color=green]
> > news:usOZ1YsWEHA.1656@TK2MSFTNGP09.phx.gbl...[color=darkred]
> > > If the OP is building an inherited control then custom properties can[/color][/color]
> be[color=green][color=darkred]
> > > bound to the properties window with an attribute tag. Maybe that would
> > > help.?
> > >
> > >
> > >
> > > --
> > >
> > > OHM ( Terry Burns )
> > > . . . One-Handed-Man . . .
> > >
> > > Time flies when you don't know what you're doing
> > >
> > > "Jay B. Harlow [MVP - Outlook]" <Jay_Harlow_MVP@msn.com> wrote in[/color][/color]
> message[color=green][color=darkred]
> > > news:upKJEKsWEHA.3740@TK2MSFTNGP12.phx.gbl...
> > > > Simon,
> > > > As far as I can tell the designer data-binding requires binding to a[/color]
> > list[color=darkred]
> > > of
> > > > items.
> > > >
> > > > I am not aware of any interface that will enable you to bind in the
> > > designer
> > > > to a single object. Other then Making your single object appear to[/color][/color][/color]
be[color=blue]
> a[color=green][color=darkred]
> > > > list, which IMHO is more work then simply adding the data binding
> > > > manually...
> > > >
> > > > Considering there is more work on defining the object to support[/color][/color][/color]
data[color=blue][color=green][color=darkred]
> > > > binding, then the databinding itself, I personally don't have a[/color][/color]
> problem[color=green][color=darkred]
> > > with
> > > > this.
> > > >
> > > > Hope this helps
> > > > Jay
> > > >
> > > > "Simon Verona" <news@aphroditeuk.com> wrote in message
> > > > news:O3OnSFqWEHA.3140@TK2MSFTNGP10.phx.gbl...
> > > > > Thanks Jay...
> > > > >
> > > > > I've got it working using the data binding in code...
> > > > >
> > > > > I'd like to be able to do the data-binding in the designer....[/color][/color][/color]
I[color=blue][color=green][color=darkred]
> > > guess
> > > > I
> > > > > need another interface?
> > > > >
> > > > > Regards
> > > > > Simon
> > > > >
> > > > > "Jay B. Harlow [MVP - Outlook]" <Jay_Harlow_MVP@msn.com> wrote in
> > > message
> > > > > news:OfumZgjWEHA.3512@TK2MSFTNGP12.phx.gbl...
> > > > > > Simon,
> > > > > > As I stated earlier: Correct! you don't need to implement any
> > > interfaces
> > > > > if
> > > > > > you have a single object ("record").
> > > > > >
> > > > > > You need to include a Text1Changed event for the Text1 property,[/color][/color]
> if[color=green][color=darkred]
> > > you
> > > > > can
> > > > > > change the object outside of the form, if only the form can[/color][/color][/color]
change[color=blue][color=green]
> > the[color=darkred]
> > > > > > object/property, then the event is not as important.
> > > > > >
> > > > > > The "Changed" event needs to be named the same as the property,[/color][/color]
> with[color=green][color=darkred]
> > > > > Changed
> > > > > > as the suffix, as my Person example shows.
> > > > > >
> > > > > > Hope this helps
> > > > > > Jay
> > > > > >
> > > > > > "Simon Verona" <news@aphroditeuk.com> wrote in message
> > > > > > news:%23Wp2iWjWEHA.2544@TK2MSFTNGP10.phx.gbl...
> > > > > > > So do I read it that I don't need to implement all the[/color][/color]
> interfaces[color=green]
> > if[color=darkred]
> > > I
> > > > > > just
> > > > > > > have a single record ????
> > > > > > >
> > > > > > > Simon
> > > > > > > "Jay B. Harlow [MVP - Outlook]" <Jay_Harlow_MVP@msn.com> wrote[/color][/color]
> in[color=green][color=darkred]
> > > > > message
> > > > > > > news:exmJUrgWEHA.3200@TK2MSFTNGP09.phx.gbl...
> > > > > > > > Terry,
> > > > > > > > > The only problem with this is that if you change the
> > > aPerson.Text1
> > > > > > value
> > > > > > > > > this is not reflected in the TextBox1
> > > > > > > > That's because I left out the notification. :-( Here is a[/color]
> > version[color=darkred]
> > > > with
> > > > > > > > Notifications. :-)
> > > > > > > >
> > > > > > > > Public Class Person
> > > > > > > >
> > > > > > > > Public Event Text1Changed As EventHandler
> > > > > > > > Public Event Text2Changed As EventHandler
> > > > > > > >
> > > > > > > > Private m_text1 As String
> > > > > > > > Private m_text2 As String
> > > > > > > >
> > > > > > > > Public Sub New()
> > > > > > > > m_text1 = String.Empty
> > > > > > > > m_text2 = String.Empty
> > > > > > > > End Sub
> > > > > > > >
> > > > > > > > Public Property Text1() As String
> > > > > > > > Get
> > > > > > > > Return m_text1
> > > > > > > > End Get
> > > > > > > > Set(ByVal value As String)
> > > > > > > > m_text1 = value
> > > > > > > > OnText1Changed(EventArgs.Empty)
> > > > > > > > End Set
> > > > > > > > End Property
> > > > > > > >
> > > > > > > > Public Property Text2() As String
> > > > > > > > Get
> > > > > > > > Return m_text2
> > > > > > > > End Get
> > > > > > > > Set(ByVal value As String)
> > > > > > > > m_text2 = value
> > > > > > > > OnText2Changed(EventArgs.Empty)
> > > > > > > > End Set
> > > > > > > > End Property
> > > > > > > >
> > > > > > > > Protected Overridable Sub OnText1Changed(ByVal e As[/color]
> > EventArgs)[color=darkred]
> > > > > > > > RaiseEvent Text1Changed(Me, e)
> > > > > > > > End Sub
> > > > > > > >
> > > > > > > > Protected Overridable Sub OnText2Changed(ByVal e As[/color]
> > EventArgs)[color=darkred]
> > > > > > > > RaiseEvent Text2Changed(Me, e)
> > > > > > > > End Sub
> > > > > > > >
> > > > > > > > End Class
> > > > > > > >
> > > > > > > > I tested the above in VS.NET 2003, Changing aPerson.Test1 in[/color][/color]
> the[color=green][color=darkred]
> > > > above
> > > > > > > > changes it in TextBox1!
> > > > > > > >
> > > > > > > > I don't have a clear link that explains the above, if you[/color][/color][/color]
want[color=blue][color=green]
> > it[color=darkred]
> > > or
> > > > > > need
> > > > > > > it
> > > > > > > > I can look for it later.
> > > > > > > >
> > > > > > > > Hope this helps
> > > > > > > > Jay
> > > > > > > >
> > > > > > > > "One Handed Man ( OHM - Terry Burns )" <news.microsoft.com>[/color]
> > wrote[color=darkred]
> > > in
> > > > > > > message
> > > > > > > > news:%23EFok9fWEHA.4064@TK2MSFTNGP11.phx.gbl...
> > > > > > > > > The only problem with this is that if you change the
> > > aPerson.Text1
> > > > > > value
> > > > > > > > > this is not reflected in the TextBox1
> > > > > > > > >
> > > > > > > > > --
> > > > > > > > >
> > > > > > > > > OHM ( Terry Burns )
> > > > > > > > > . . . One-Handed-Man . . .
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > "Jay B. Harlow [MVP - Outlook]" <Jay_Harlow_MVP@msn.com>[/color][/color]
> wrote[color=green][color=darkred]
> > > in
> > > > > > > message
> > > > > > > > > news:OCEln3fWEHA.3420@TK2MSFTNGP12.phx.gbl...
> > > > > > > > > > Simon,
> > > > > > > > > > As OHM suggested, you need to implement IList,[/color][/color]
> ICollection,[color=green][color=darkred]
> > > > > > > IEnumerable
> > > > > > > > if
> > > > > > > > > > you want to "edit" a list of items. If you have a single[/color]
> > item,[color=darkred]
> > > > you
> > > > > > do
> > > > > > > > not
> > > > > > > > > > need to implement those interfaces.
> > > > > > > > > >
> > > > > > > > > > In my experience IEditableObject is useful but not[/color][/color]
> required[color=green]
> > to[color=darkred]
> > > > > > change
> > > > > > > > > bound
> > > > > > > > > > data, if you fully implement IEditableObject you can[/color][/color]
> cancel[color=green][color=darkred]
> > > the
> > > > > > > change,
> > > > > > > > > > without IEditableObject the change is made, period.
> > > > > > > > > >
> > > > > > > > > > This article appears to be a good starting point on data
> > > > binding.
> > > > > > > > > >[/color]
> >
http://support.microsoft.com/default...b;en-us;313482[color=darkred]
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > Here is a simple sample of binding to an Object:
> > > > > > > > > >
> > > > > > > > > > Public Class Person
> > > > > > > > > >
> > > > > > > > > > Private m_text1 As String
> > > > > > > > > > Private m_text2 As String
> > > > > > > > > >
> > > > > > > > > > Public Sub New()
> > > > > > > > > > m_text1 = String.Empty
> > > > > > > > > > m_text2 = String.Empty
> > > > > > > > > > End Sub
> > > > > > > > > >
> > > > > > > > > > Public Property Text1() As String
> > > > > > > > > > Get
> > > > > > > > > > Return m_text1
> > > > > > > > > > End Get
> > > > > > > > > > Set(ByVal value As String)
> > > > > > > > > > m_text1 = value
> > > > > > > > > > End Set
> > > > > > > > > > End Property
> > > > > > > > > >
> > > > > > > > > > Public Property Text2() As String
> > > > > > > > > > Get
> > > > > > > > > > Return m_text2
> > > > > > > > > > End Get
> > > > > > > > > > Set(ByVal value As String)
> > > > > > > > > > m_text2 = value
> > > > > > > > > > End Set
> > > > > > > > > > End Property
> > > > > > > > > >
> > > > > > > > > > End Class
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > Public Class PersonForm
> > > > > > > > > > Inherits System.Windows.Forms.Form
> > > > > > > > > >
> > > > > > > > > > ' ... designer generated code
> > > > > > > > > >
> > > > > > > > > > Private aPerson As New Person
> > > > > > > > > >
> > > > > > > > > > Private Sub SamSpadeForm_Load(ByVal sender As[/color][/color][/color]
Object,[color=blue][color=green][color=darkred]
> > > ByVal
> > > > e
> > > > > As
> > > > > > > > > > System.EventArgs) Handles MyBase.Load
> > > > > > > > > > Me.TextBox1.DataBindings.Add("Text", aPerson,[/color]
> > "Text1")[color=darkred]
> > > > > > > > > > Me.TextBox2.DataBindings.Add("Text", aPerson,[/color]
> > "Text2")[color=darkred]
> > > > > > > > > > End Sub
> > > > > > > > > >
> > > > > > > > > > End Class
> > > > > > > > > >
> > > > > > > > > > Hope this helps
> > > > > > > > > > Jay
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > "Simon Verona" <news@aphroditeuk.com> wrote in message
> > > > > > > > > > news:e3kesKdWEHA.4020@TK2MSFTNGP09.phx.gbl...
> > > > > > > > > > > I'm not sure if I'm going down the correct route...
> > > > > > > > > > >
> > > > > > > > > > > I have a class which exposes a number of properties of[/color][/color]
> an[color=green][color=darkred]
> > > > object
> > > > > > (in
> > > > > > > > > this
> > > > > > > > > > > case the object represents a customer). Can I then[/color][/color]
> use[color=green][color=darkred]
> > > > this
> > > > > > > object
> > > > > > > > > to
> > > > > > > > > > > databind to text boxes etc?
> > > > > > > > > > >
> > > > > > > > > > > I can't use a dataset as the object has loads of[/color][/color][/color]
derived[color=blue][color=green][color=darkred]
> > > > logic,
> > > > > > for
> > > > > > > > > > example
> > > > > > > > > > > updating one property may actually update several[/color][/color]
> database[color=green][color=darkred]
> > > > > fields
> > > > > > > for
> > > > > > > > > > > example.
> > > > > > > > > > >
> > > > > > > > > > > Hope I've explained this clear enough...
> > > > > > > > > > >
> > > > > > > > > > > Regards
> > > > > > > > > > > Simon
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >[/color]
> >
> >[/color]
>
>[/color]