×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Getting Value of Databound Composite Control Back to Form

Getting Value of Databound Composite Control Back to Form

Getting Value of Databound Composite Control Back to Form

(OP)
I made a composite control from a maskedtextbox and a datetimepicker to make it easier for a user to enter a date with the keyboard. I also added a property to bind the dtp on the composite control to the bindingsource on my windows form (see below). I also set up a property to return the dtp vlaue. Without explicitly calling the value property and setting the correct data table column to this value, how do I get the value back to the form. I can use the code in the second block below but it seems like I should be able to bind this composite control and not have to call the value property. If I don't do it this way the form never sees the value set in the composite control. Must be a better way. Do I have to bind using a different method? Any suggestions? I would like it to behave like a normal datetimepicker.

CODE

'Property in Composite Control
Public Property propBindingSource() As BindingSource
    Get
      Return (bs)
    End Get
    Set(ByVal value As BindingSource)
      bs = New BindingSource
      bs = value
      dtpDate.DataBindings.Add("Text", bs, "InvoiceDate")
    End Set
  End Property 

CODE

'Code in Form to Get the Value
dt.Rows(0).Item("InvoiceDate") = MyDateTimePicker1.propValue 

Auguy
Sylvania/Toledo Ohio

RE: Getting Value of Databound Composite Control Back to Form

The Set part of the property is the problem:

Set(ByVal value As BindingSource)

Change the ByVal to ByRef and it will pass the bindingsource from the parent, instead of passing a copy as with ByVal.

I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson

Arrrr, mateys! Ye needs ta be preparin' yerselves fer Talk Like a Pirate Day!

RE: Getting Value of Databound Composite Control Back to Form

(OP)
Thanks. I tried that and I get error "set parameter cannot be declared byref". Do I need to change the property definition. Not sure I can do that.

Auguy
Sylvania/Toledo Ohio

RE: Getting Value of Databound Composite Control Back to Form

Oops, my bad. I've never actually tried using ByRef in a property Set before...I just learned something.


I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson

Arrrr, mateys! Ye needs ta be preparin' yerselves fer Talk Like a Pirate Day!

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close