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.
Re: How to create an ActiveX control (grid) with DataSource and DataMember property?
Lets start with what have you tried that isn't working?
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:
'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
'MappingInfo=DataGrid1,DataGrid1,-1,DataSource
Public Property Get DataSource() As DataSource
Set DataSource = DataGrid1.DataSource
End Property
Public Property Set DataSource(ByVal New_DataSource As DataSource)
Set DataGrid1.DataSource = New_DataSource
PropertyChanged "DataSource"
End Property
'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
'MappingInfo=DataGrid1,DataGrid1,-1,DataMember
Public Property Get DataMember() As String
DataMember = DataGrid1.DataMember
End Property
Public Property Let DataMember(ByVal New_DataMember As String)
DataGrid1.DataMember() = New_DataMember
PropertyChanged "DataMember"
End Property
'Load property values from storage
Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
Set DataSource = PropBag.ReadProperty("DataSource", Nothing)
DataGrid1.DataMember = PropBag.ReadProperty("DataMember", "")
End Sub
'Write property values to storage
Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
Call PropBag.WriteProperty("DataSource", DataSource, Nothing)
Call PropBag.WriteProperty("DataMember", DataGrid1.DataMember, "")
End Sub
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!
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?