Results 1 to 5 of 5

Thread: How to create an ActiveX control (grid) with DataSource and DataMember property?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 2005
    Posts
    81

    How to create an ActiveX control (grid) with DataSource and DataMember property?

    I try to create a new grid activex control. I placed a grid onto the UserControl. I trying publish its DataSource and DataMember properties, but I cant .

    plz help, I tried everything out and doesnt work.

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: How to create an ActiveX control (grid) with DataSource and DataMember property?

    Lets start with what have you tried that isn't working?

  3. #3
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: How to create an ActiveX control (grid) with DataSource and DataMember property?

    Which Grid control are you using?

    If you are using the Microsoft DataGrid Control (6.0) then make sure the VB Project that contains the user control has a reference to the Microsoft Data Source Interfaces library.

    The following code for the DataSource, DataMember properties was generated by the UserControl Wizard. I did not test to see if it was correct.

    VB Code:
    1. 'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
    2. 'MappingInfo=DataGrid1,DataGrid1,-1,DataSource
    3. Public Property Get DataSource() As DataSource
    4.     Set DataSource = DataGrid1.DataSource
    5. End Property
    6.  
    7. Public Property Set DataSource(ByVal New_DataSource As DataSource)
    8.     Set DataGrid1.DataSource = New_DataSource
    9.     PropertyChanged "DataSource"
    10. End Property
    11.  
    12. 'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
    13. 'MappingInfo=DataGrid1,DataGrid1,-1,DataMember
    14. Public Property Get DataMember() As String
    15.     DataMember = DataGrid1.DataMember
    16. End Property
    17.  
    18. Public Property Let DataMember(ByVal New_DataMember As String)
    19.     DataGrid1.DataMember() = New_DataMember
    20.     PropertyChanged "DataMember"
    21. End Property
    22.  
    23. 'Load property values from storage
    24. Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
    25.  
    26.     Set DataSource = PropBag.ReadProperty("DataSource", Nothing)
    27.     DataGrid1.DataMember = PropBag.ReadProperty("DataMember", "")
    28. End Sub
    29.  
    30. 'Write property values to storage
    31. Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
    32.  
    33.     Call PropBag.WriteProperty("DataSource", DataSource, Nothing)
    34.     Call PropBag.WriteProperty("DataMember", DataGrid1.DataMember, "")
    35. End Sub

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Jun 2005
    Posts
    81

    Re: How to create an ActiveX control (grid) with DataSource and DataMember property?

    My project had no reference to the Microsoft Data Source Interfaces library.
    It would be the problem.

    thx very much, i will try it!

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Jun 2005
    Posts
    81

    Re: How to create an ActiveX control (grid) with DataSource and DataMember property?

    It works, but more questions:

    The grid I use have no datasource and datamember. I use variables to store these values:
    Dim m_DataSource As Object
    Dim m_DataMember As String

    My problem:
    -A normal data-bound grid lists the possible values for DataMember property when the user selected the DataSource, but mine dont.

    -I obtain the recordset in the following way:
    Public WithEvents rst As ADODB.Recordset
    Set rst = m_DataSource.Recordsets(m_DataMember)
    ,but I cant do this when the DataMember is a "child recordset" of a parent-child relation recordset.

    Can u help me?

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