Tuesday, April 16, 2013

Sharing Everything From My Experience And Knowlegde

Sharing Everything From My Experience And Knowlegde


Perbedaan Items.Add dan Items.AddRange (ComboBox, ListBox, CheckedListBox, Listivew) VBNET

Posted: 15 Apr 2013 08:11 PM PDT

Salah satu kelebihan VBNET adalah adanya method .AddRange pada object seperti : ComboBox, ListBox, Listivew, dll. Apa bedanya .Add dengan .AddRange ?
1.Add adalah fungsi untuk menambahkan suatu nilai (item/row) pada suatu object satu persatu (one by one)
2.AddRange adalah fungsi untuk menambahkan suatu nilai (item/row) pada suatu object sekaligus (using array)
sehingga AddRange Ini JAUH lebih cepat prosesnya serta sintak nya pun jauh lebih pendek/singkat dari pada fungsi .Add.
Contoh .Add pada ComboBox, ListBox, CheckedListBox :

        WithComboBox1
            .Items.Add("A")
            .Items.Add("B")
            .Items.Add("C")
        End With
Tetapi dengan .AddRange anda cukup menulis sintak seperti ini :

        WithComboBox1
            .Items.AddRange(New String() {"A", "B", "C"})
        End With
        'ATAU
        DimmyArray() As String= {"A", "B", "C"}
        WithComboBox1
            .Items.AddRange(myArray)
        End With

Contoh .Add pada Listivew :

        WithListView1
            .Items.Add("A")
            .Items(.Items.Count - 1).SubItems.Add("subitem1")
            .Items(.Items.Count - 1).SubItems.Add("subitem2")
            .Items(.Items.Count - 1).SubItems.Add("subitem3")
        End With
Dengan .AddRange anda cukup menulis sintak seperti ini :

        WithListView1
            .Items.Add("A").SubItems.AddRange(New String() {"subitem1", "subitem2", "subitem3"})
        End With

Tags:
AddRange vs add vbnet, cara cepat att item , contoh add item listview vbnet, contoh cara additem combobox vbnet, contoh cara add item checkedlistbox vbnet

Delete/Remove Checked Items/Rows Listivew/Datagridview VBNET

Posted: 15 Apr 2013 07:02 PM PDT

Ini merupakan kelajutan dari "Remove Selected Item/Row Listview/Datagridview". jika sebelumnya menghapus/remove item/row yang dipilih/diblok (multi selected), sekarang bagaimana menghapus/remove row yang di checklist (asumsi kolom pertama = checkbox). Begini sintaknya :
1.DataGridView

Private Sub djieButtonDelete_Click(ByValsender As System.Object, ByVal e AsSystem.EventArgs) HandlesdjieButtonDelete.Click
DoRemove:
        For Each row AsDataGridViewRow In DataGridView1.Rows
            Ifrow.Cells(0).Value = True Then 'checked
                DataGridView1.Rows.Remove(row)
                GoToDoRemove
            EndIf
        Next
End Sub

2.ListView

Private Sub djieButtonDelete_Click(ByValsender As System.Object, ByVal e AsSystem.EventArgs) HandlesdjieButtonDelete.Click
        For Each item AsListViewItem In ListView1.CheckedItems
            item.Remove()
        Next
End Sub

Tags:
remove checked item , cara hapus item yang di checklish di listivew, remove row yang dichecklish di datagridview,


No comments:

Post a Comment