Halo sobat, kesibukan yang membuat saya tidak sempat posting blog. Kangen juga lama tidak posting. Kali ini saya akan berbagi sedikit tips yaitu masih dengan MSHFlexgrid. Tips kali ini adalah mewarnai baris selang seling dan juga saya tambahkan penomoran otomatis. Langsung saja kita praktekkan.
Buka program Visual Basic 6 nya.
- Tambahkan 1 Form : Form1 (default), namun saya rubah (Name) menjadi FormUtama
- Tambahkan Microsoft ActiveX Data Objects 2.1 Library
- Tambahkan Microsoft Hierarchical Flexgrid Control 6.0 (OLEDB)
Caranya : Klik menu Project => Component , lalu centang Microsoft Hierarchical Flexgrid Control 6.0 (OLEDB), lalu klik OK
Private Con As New ADODB.ConnectionJika program di Run, maka hasilnya akan seperti dibawah ini
Private Rs As New ADODB.Recordset
Private Sql As String
Private Sub Command1_Click()
Unload Me
End Sub
Private Sub Form_Load()
Con.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=./DBDataNasabah.mdb;Persist Security Info=False"
Sql = "SELECT * FROM NASABAH"
Rs.Open Sql, Con, adOpenStatic
Set MSHFlexGrid1.Recordset = Rs
Call Warna
Call Penomoran
Call Kolom
End Sub
Private Function Warna()
Dim j As Integer
Dim i As Integer
For j = 0 To MSHFlexGrid1.Cols - 1
For i = 1 To MSHFlexGrid1.Rows - 1
If i / 2 <> Int(i / 2) Then
MSHFlexGrid1.Col = j
MSHFlexGrid1.Row = i
MSHFlexGrid1.CellBackColor = &HFFFF& 'Warna Kuning, sobat bisa berkreasi
End If
Next i
Next j
End Function
Private Function Penomoran()
Dim Y%
On Error Resume Next
With MSHFlexGrid1
.ColAlignment(-1) = 1
For Y% = 1 To MSHFlexGrid1.Rows - 1
.TextMatrix(Y%, 0) = Str(Y%)
Next
.Row = 1
.Col = 1
End With
End Function
Sub Kolom()
With MSHFlexGrid1
.Cols = 5
.RowHeightMin = 300
.Col = 0
.Row = 0
.Text = "No."
.CellFontBold = True
.ColWidth(0) = 400
.AllowUserResizing = flexResizeColumns
.CellAlignment = flexAlignCenterCenter
.Col = 1
.Row = 0
.Text = "Nokontrak"
.CellFontBold = True
.ColWidth(1) = 1400
.AllowUserResizing = flexResizeColumns
.CellAlignment = flexAlignCenterCenter
.Col = 2
.Row = 0
.Text = "Nama"
.CellFontBold = True
.ColWidth(2) = 2400
.AllowUserResizing = flexResizeColumns
.CellAlignment = flexAlignCenterCenter
.Col = 3
.Row = 0
.Text = "Plafond"
.CellFontBold = True
.ColWidth(3) = 1400
.AllowUserResizing = flexResizeColumns
.CellAlignment = flexAlignCenterCenter
.Col = 4
.Row = 0
.Text = "Margin"
.CellFontBold = True
.ColWidth(4) = 1400
.AllowUserResizing = flexResizeColumns
.CellAlignment = flexAlignCenterCenter
End With
End Sub
Semoga tips ini bermanfaat ...
Download Source Code
Posted by 2:53:00 PM and have
0
comments
, Published at
No comments:
Post a Comment