Results 1 to 8 of 8

Thread: How to map Datasource property?

  1. #1

    Thread Starter
    Lively Member Yok's Avatar
    Join Date
    Feb 2001
    Location
    Guangzhou,China
    Posts
    72

    How to map Datasource property?

    There's a listbox in my control, and I want to map it's datasource to my control,How can I do that?
    And what's DataSource's type? Active Control Interface Wizard declear it as DataSourse e.g:
    Public Property Get DataSource() As Recordset
    but an error will occur and prompt that DataSourse is an undefined type.

  2. #2
    jim mcnamara
    Guest
    Try:

    Public Property Get DataSource() As Variant

    Internally treat DataSource as a datatype of Object or RecordSet

    The client can pass anything as a Variant.

  3. #3
    PowerPoster Arc's Avatar
    Join Date
    Sep 2000
    Location
    Under my rock
    Posts
    2,336
    That seems theasable jim. But whatabout vb.net where a variant isn't an option?

    I think there is a better way to do this. I'll find out.
    -We have enough youth. How about a fountain of "Smart"?
    -If you can read this, thank a teacher....and since it's in English, thank a soldier.


  4. #4
    PowerPoster Arc's Avatar
    Join Date
    Sep 2000
    Location
    Under my rock
    Posts
    2,336
    OK i figured it out It's a little complex so stay with me


    1) CHange the Usercontrols DataBindingBehavior to vbSimpleBound in the propertys window.

    2)Make sure your cursor is in the code window for your usercontrol, preferably in one of the Property procedures of the property you wish to reflect the bound data.

    3) Choose the Tools, Procedure Attributes option form the VB menu.

    4) On the resulting dialog box, make sure the property that will reflect the bound data is chosen in the names field.

    5) CLick the Advanced button

    6) in the databinding section at the bottom of the dialog, check the box labeled "Property is databound", and then chekc the box labeled "This property binds to datafield"



    That should create the Dtabound and datasource propertys you need
    Last edited by Arc; Apr 29th, 2002 at 08:23 PM.
    -We have enough youth. How about a fountain of "Smart"?
    -If you can read this, thank a teacher....and since it's in English, thank a soldier.


  5. #5

    Thread Starter
    Lively Member Yok's Avatar
    Join Date
    Feb 2001
    Location
    Guangzhou,China
    Posts
    72
    I did it as you said and I can select DataSource and DataField in the properties window now.But it prompt that "Unable to bind to field:CompanyName".Why?
    (I used Nwind.mdb)

  6. #6
    PowerPoster Arc's Avatar
    Join Date
    Sep 2000
    Location
    Under my rock
    Posts
    2,336
    Well, did you conect it to a data control? in order to use the databinding cappabilities you have to be bound to a data control.

    I tried it and got no errors.
    -We have enough youth. How about a fountain of "Smart"?
    -If you can read this, thank a teacher....and since it's in English, thank a soldier.


  7. #7

    Thread Starter
    Lively Member Yok's Avatar
    Join Date
    Feb 2001
    Location
    Guangzhou,China
    Posts
    72
    Would you please send me your sample project?
    My e-Mail adress:
    [email protected]
    or [email protected]

  8. #8
    New Member
    Join Date
    Jul 2005
    Posts
    1

    Re: How to map Datasource property?

    Quote Originally Posted by Arc
    OK i figured it out It's a little complex so stay with me

    1) CHange the Usercontrols DataBindingBehavior to vbSimpleBound in the propertys window.

    2)Make sure your cursor is in the code window for your usercontrol, preferably in one of the Property procedures of the property you wish to reflect the bound data.

    3) Choose the Tools, Procedure Attributes option form the VB menu.

    4) On the resulting dialog box, make sure the property that will reflect the bound data is chosen in the names field.

    5) CLick the Advanced button

    6) in the databinding section at the bottom of the dialog, check the box labeled "Property is databound", and then chekc the box labeled "This property binds to datafield"

    That should create the Dtabound and datasource propertys you need
    I have a question about this. I have several controls that I created myself which use this method of databinding. It works wonderfully in design-time. However, when I try to assign the DataSource property of my control in run-time (w/code) I get "Method or Data Member not found." Why is this?? Is there a solution? You seem to be the most knowledgable person I have seen around yet. please, help. ;(

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width