This is a migrated thread and some comments may be shown as answers.

Error MCCB

0 Answers 11 Views
This is a migrated thread and some comments may be shown as answers.
Hengky
Top achievements
Rank 1
Veteran
Hengky asked on 17 Feb 2016, 08:47 AM

Hello All...

I need help about MCCB...

Why the data always change to blank after i click new button or edit button 

hope attached picture help to explain the problem 

 Here the code i write on Form_load 

ds = New DataSet("Daftar")
 
        Tblanggota = ds.Tables.Add("Anggota")
        With Tblanggota
            .Columns.Add("KODE", GetType(String))
            .Columns.Add("NAMA", GetType(String))
        End With
        'fill TblAnggota
 
        Using conn As New OleDbConnection(str)
            conn.Open()
            Using cmd = conn.CreateCommand()
                'mengisikan data Anggota.
                Dim query = <sql>
                                 SELECT KodeAnggota as KODE, NamaAnggota as NAMA FROM MstAnggota ORDER BY KodeAnggota
                             </sql>.Value()
                cmd.CommandText = query
                Dim adapter = New OleDbDataAdapter(cmd)
                adapter.SelectCommand = cmd
                Tblanggota.Rows.Add(New Object() {"", ""})
                adapter.Fill(Tblanggota)
            End Using
            With CmbAnggota
                .DataSource = Tblanggota
                '.SelectedValue = ""
                .AutoSizeDropDownToBestFit = True
                .BestFitColumns()
                .AutoFilter = True
                .DisplayMember = "KODE"
                .ValueMember = "KODE"
                .Text = ""
                TxtNamaAnggota.Text = ""
 
                'Dim filter As New FilterDescriptor()
                'filter.PropertyName = Me.CmbAnggota.DisplayMember
                'filter.[Operator] = FilterOperator.Contains
                'Me.CmbAnggota.EditorControl.MasterTemplate.FilterDescriptors.Add(filter)
                'CmbAnggota.MultiColumnComboBoxElement.EditorControl.EnableCustomFiltering = True
 
                'AddHandler CmbAnggota.MultiColumnComboBoxElement.EditorControl.CustomFiltering, AddressOf CmbAnggota_CustomFiltering
                'AddHandler CmbAnggota.KeyDown, AddressOf CmbAnggota_KeyDown
 
 
            End With
 
            conn.Close()
        End Using
 
        TxtNamaAnggota.DataBindings.Add("Text", Tblanggota, "NAMA")

I have tried to move the code on button_click event. but the i got the same result.

 

Thanks before

No answers yet. Maybe you can help?

Asked by
Hengky
Top achievements
Rank 1
Veteran
Share this question
or