Use of the DataGrid control in VB (v)

Source: Internet
Author: User
Tags case statement

Programming for Recordset Events
You can also program the events of this Recordset object. In the class module, click the Object box (in the upper-left corner), and then click Rsnames. In the Procedure/Event box (in the upper-right corner), the Drop-down list displays all the events for this Recordset object.

Add a property to a class
A class module can also be modified to respond to an event or function call. The following code shows how to add a property to a class first. This property returns the RecordCount of the class when the object is called from another object.
Public Property Get RecordCount () as Long
RecordCount = Rsnames.recordcount
End Sub

Using the DataMember property
The getDataMember event also includes the DataMember parameter. With this parameter, you can include more than one recordset in the class module and use the Select case statement with the DataMember parameter to return the corresponding Recordset:
Private Sub Class_getdatamember (ByVal DataMember as String, Data as _
Object)
Select Case DataMember
Case "Names"
Set Data = rsnames
Case "Dates"
Set Data = rsdates
Case Else
' Set a default data member
Set Data = Rsyears
End Select
End Sub
If you want to specify the desired DataMember, set the data consumer's DataMember property to the appropriate string, and then set the DataSource as usual. For the DataGrid control, you can use the following methods:
Private Sub Form_Load ()
' Create a new Namesdata object
Set datnames = New namesdata
' Specify the desired DataMember, and then set the DataSource.
DataGrid1.DataMember = "Names"
Set DataGrid1.DataSource = Datnames
End Sub

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.