Mas Eko, thank u buat contohnya, yg saya mo nanya dari drop down itu
untuk tampilin data doank atau kita pilih dari drop down trus muncul
datanya di grid ? yg saya mau cari adl grid nya kita kasi drop down,
nah dari drop down itu saya konek dgn database untuk tampilin no
account, begitu kode account itu dipilih, maka di grid akan muncul
nama accountnya. Gimana yach mas kalo gini ? Sama ada pertanyaan,
gimana caranya kalo kita bikin tombol save untuk menyimpan input
kita, soalnya kalo properties dari grid allow add new, sama allow
update di set true, kalo pake grid.update kalo ganti row akan error,
gimana yach mas, saya baru belajar pake true dbgrid. Thank U !
> Coba coding dibawah ini, database yg saya gunakan adalah
BIBLIO.MDB
> sample dari MS Visual Studio dan mohon maaf sebelumnya jika contoh
> di sini terlalu panjang dan sulit dibaca, saya sebenarnya mau
ngirim
> message ke milist dengan format HTML bukan text seperti ini tapi
> kagak bisa-bisa (maklum agak gaptek hehehehe), mungkin rekan2 ada
yg
> tau gimana cara send message berupa HTML di milist.
>
> Contoh disini sudah saya lengkapi dengan setting
> AlternatingBackcolor sehingga tampilan lebih indah dilihat. Contoh
> selengkapnya spt dibawah ini
> 1.Buka aplikasi anda
> 2.Tambahkan component one True DBGrid Pro 8.0 (OLEDB8)
> 3.Tambahkan component one True DBList Pro 8.0 (OLEDB8)
> 4.Pasang component TDBGrid dan TDBDropDown ke Form anda, ubah
> property name TDBGrid menjadi Grid dan TDBDropDown menjadi DrpDwn
> 5.Tambahkan Module, dan ketikkan code spt dibawah ini
> -----------------------------------------------------
> 'Color Standard
> Private Function WarnaBiru() As Long
> On Error Resume Next
> WarnaBiru = RGB(41, 129, 207)
> End Function
>
> 'Color Standard
> Private Function WarnaHijau() As Long
> On Error Resume Next
> WarnaHijau = RGB(0, 128, 0)
> End Function
>
> 'Color Standard
> Private Function WarnaGrid() As Long
> On Error Resume Next
> WarnaGrid = RGB(236, 233, 216)
> End Function
>
> 'Color Standard
> Private Function WarnaEvenRow() As Long
> On Error Resume Next
> WarnaEvenRow = RGB(240, 248, 255)
> End Function
>
> Public Sub ClearGridLayout(ByRef vObj As TDBGrid)
> On Error Resume Next
> vObj.ClearFields
> While vObj.Columns.Count <> 0
> vObj.Columns.Remove 0
> Wend
> End Sub
>
> 'Used to set True DBGrid layout
> Public Sub SetGridLayout(ByRef vObj As TDBGrid)
> On Error Resume Next
> With vObj
> Dim Col As TrueOleDBGrid80.Column
> For Each Col In vObj.Columns
> Col.DividerColor = WarnaGrid
> Col.DividerStyle = dbgCustomColor
> Next
> .Appearance = dbgXPTheme
> .AllowColSelect = False
> .AllowRowSizing = False
> .AlternatingRowStyle = True
> .BorderStyle = dbgFixedSingle
> .CaptionStyle.Alignment = dbgLeft
> .CaptionStyle.Font.Bold = False
> .CaptionStyle.ForeColor = WarnaBiru
> .DeadAreaBackColor = vbWhite
> .DirectionAfterEnter = dbgMoveRight
> .ExtendRightColumn = True
> .Font = TaFont
> .HeadingStyle.Alignment = dbgCenter
> .HeadingStyle.BackColor = vbButtonFace
> .HeadingStyle.Font = TaFont
> .PartialRightColumn = False
> .RecordSelectorStyle.BackColor = vbButtonFace
> .RecordSelectorWidth = 255
> .RowDividerColor = WarnaGrid
> .RowDividerStyle = dbgCustomColor
> .ScrollTrack = True
> .Styles("EvenRow").BackColor = WarnaEvenRow
> .Refresh
> End With
> End Sub
>
> 'Used to clear TDBCombo layout
> Public Sub ClearComboLayout(ByRef vObj As TDBCombo)
> On Error Resume Next
> vObj.ClearFields
> While vObj.Columns.Count <> 0
> vObj.Columns.Remove 0
> Wend
> End Sub
>
> 'Used to set TDBCombo layout
> Public Sub SetComboLayout(ByRef vObj As TDBCombo)
> On Error Resume Next
> Dim Col As TrueOleDBList80.Column
> With vObj
> For Each Col In vObj.Columns
> Col.DividerStyle = dblLightGrayLine
> Next
> .Appearance = dbl3D
> .AllowColSelect = False
> .AllowRowSizing = False
> .AlternatingRowStyle = True
> .AutoCompletion = True
> .AutoDropDown = True
> .BorderStyle = dblFixedSingle
> .ColumnHeaders = False
> .Font = TaFont
> .HeadingStyle.Alignment = dblCenter
> .HeadingStyle.BackColor = vbButtonFace
> .HeadingStyle.Font = TaFont
> .LimitToList = True
> .MaxComboItems = 15
> .RowDividerColor = WarnaGrid
> .RowDividerStyle = dbgCustomColor
> .ScrollTrack = True
> .Styles("EvenRow").BackColor = WarnaEvenRow
> .Refresh
> End With
> End Sub
>
> 'Used to clear TDBDropDown layout
> Public Sub ClearDropDownLayout(ByRef vObj As TDBDropDown)
> On Error Resume Next
> vObj.ClearFields
> While vObj.Columns.Count <> 0
> vObj.Columns.Remove 0
> Wend
> End Sub
>
> 'Used to set TDBDropDown layout
> Public Sub SetDropDownLayout(ByRef vObj As TDBDropDown)
> On Error Resume Next
> Dim Col As TrueOleDBList80.Column
> With vObj
> For Each Col In vObj.Columns
> Col.DividerStyle = dblLightGrayLine
> Next
> .Appearance = dbgXPTheme
> .AllowColSelect = False
> .AllowRowSizing = False
> .AlternatingRowStyle = True
> .BorderStyle = dbgFixedSingle
> .ColumnHeaders = False
> .DeadAreaBackColor = vbWhite
> .ExtendRightColumn = True
> .Font = TaFont
> .HeadingStyle.Alignment = dbgCenter
> .HeadingStyle.BackColor = vbButtonFace
> .HeadingStyle.Font = TaFont
> .RowDividerColor = WarnaGrid
> .RowDividerStyle = dbgCustomColor
> .ScrollTrack = True
> .Styles("EvenRow").BackColor = WarnaEvenRow
> .Refresh
> End With
> End Sub
> ---------------------------------------------------------
> 6.Kembali ke Form, dan tambahkan code seperti dibawah ini
> ---------------------------------------------------------
> Private Const cstring As String
> = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
> "C:\Program Files\Microsoft Visual Studio\VB98\BIBLIO.MDB;Persist
> Security Info=False"
>
> Dim cn As ADODB.Connection
> Dim rsAuthors As ADODB.Recordset
> Dim rsTittleAuthor As ADODB.Recordset
>
> Private Sub Form_Load()
> Set cn = New ADODB.Connection
> cn.ConnectionString = cstring
> cn.CursorLocation = adUseClient
> cn.Open
>
> Set rsAuthors = New ADODB.Recordset 'cn.Execute("SELECT * FROM
> Authors")
> With rsAuthors
> Set .ActiveConnection = cn
> .LockType = adLockPessimistic
> .CursorType = adOpenStatic
> .Source = "SELECT * FROM Authors"
> .Open
> Set .ActiveConnection = Nothing
> End With
>
> Set Grid.DataSource = rsAuthors
> gridSetting
>
> Set rsTitleAuthor = cn.Execute("SELECT * FROM [Title Author]")
> Set DrpDwn.DataSource = rsTitleAuthor
> DropDownSetting
> End Sub
>
> Private Sub gridSetting()
> Dim colGrid As TrueOleDBGrid80.Column
> ClearGridLayout Grid
> With Grid
> .HeadLines = 1
> .Splits(0).AllowSizing = True
> .MultiSelect = dbgMultiSelectSimple
> Set colGrid = .Columns.Add(0): colGrid.Caption = "AU ID":
> colGrid.Visible = True: colGrid.Locked = False: colGrid.Width =
> 1000: colGrid.AllowFocus = True: colGrid.DataField = "AU_ID":
> colGrid.DropDown = "DrpDwn": colGrid.DropDownList = True:
> colGrid.AutoDropDown = True: colGrid.Button = True
> Set colGrid = .Columns.Add(1): colGrid.Caption
= "Authors":
> colGrid.Visible = True: colGrid.Locked = False: colGrid.Width =
> 1500: colGrid.AllowFocus = False: colGrid.DataField = "Author"
> Set colGrid = .Columns.Add(2): colGrid.Caption = "Year
> Born": colGrid.Visible = True: colGrid.Locked = False:
colGrid.Width
> = 800: colGrid.AllowFocus = False: colGrid.DataField = "Year Born"
> Set colGrid = .Columns.Add(3): colGrid.Caption = "":
> colGrid.Visible = True: colGrid.Locked = True: colGrid.Width = 0:
> colGrid.AllowFocus = False
> .HoldFields
> End With
> SetGridLayout Grid
> End Sub
>
> Private Sub DropDownSetting()
> Dim colGrid As TrueOleDBGrid80.Column
> ClearDropDownLayout DrpDwn
> With DrpDwn
> Set colGrid = .Columns.Add(0): colGrid.Caption = "AU ID":
> colGrid.Visible = True: colGrid.Locked = False: colGrid.Width =
> 1000: colGrid.AllowFocus = True: colGrid.DataField = "AU_ID"
> Set colGrid = .Columns.Add(1): colGrid.Caption = "ISBN":
> colGrid.Visible = True: colGrid.Locked = False: colGrid.Width =
> 1500: colGrid.AllowFocus = False: colGrid.DataField = "ISBN"
> Set colGrid = .Columns.Add(2): colGrid.Caption = "":
> colGrid.Visible = True: colGrid.Locked = True: colGrid.Width = 0:
> colGrid.AllowFocus = False
> .ListField = "AU_ID"
> .Width = 4000
> .HoldFields
> End With
> SetDropDownLayout DrpDwn
> End Sub
Untuk berhenti berlangganan kirim email kosong ke : [EMAIL PROTECTED]
Ikuti juga forum diskusi VB.net dengan
mengirim email kosong ke [EMAIL PROTECTED]
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/indoprog-vb/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/