.:: Jasa Membuat Aplikasi Website,Desktop,Android Order Now..!! | | Order Now..!! Jasa Membuat Project Arduino,Robotic,Print 3D ::.

How to use a combobox

0 komentar


بِسْــــــــــــــــمِ اﷲِالرَّحْمَنِ اارَّحِيم
bismillaahirrahmaanirrahiim

السَّلاَمُ عَلَيْكُمْ وَرَحْمَةُ اللهِ وَبَرَكَاتُهُ
Assalamu'alaikum warahmatullahi wabarakatuh

How to use a combobox


Add a combobox in a form, and resize it.

Then, in the code, we adjust the properties. I choose to do at the start of the form. You can also do the same thing.


    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        ComboBox1.BackColor = Color.Ivory
        ComboBox1.Enabled = True
        ComboBox1.Visible = True
        ComboBox1.FlatStyle = FlatStyle.Standard

    End Sub



When the combobox is initialized and when the properties satisfies you, we can add words to the combobox. We could remain in the same function and start adding text right after.


    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        ComboBox1.BackColor = Color.Ivory
        ComboBox1.Enabled = True
        ComboBox1.Visible = True
        ComboBox1.FlatStyle = FlatStyle.Standard


        ComboBox1.Items.Add("John")
        ComboBox1.Items.Add("Peter")
        ComboBox1.Items.Add("Kevin")


    End Sub



Now that you put information in the combobox, it is good idea to set an initial choice.




    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        ComboBox1.BackColor = Color.Ivory
        ComboBox1.Enabled = True
        ComboBox1.Visible = True
        ComboBox1.FlatStyle = FlatStyle.Standard


        ComboBox1.Items.Add("John")
        ComboBox1.Items.Add("Peter")
        ComboBox1.Items.Add("Kevin")

        ComboBox1.SelectedIndex = 2 'will display Peter
    End Sub



You can also enhance the use of the combobox by sorting alphabetically with the command shorted.




    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        ComboBox1.BackColor = Color.Ivory
        ComboBox1.Enabled = True
        ComboBox1.Visible = True
        ComboBox1.FlatStyle = FlatStyle.Standard


        ComboBox1.Items.Add("John")
        ComboBox1.Items.Add("Peter")
        ComboBox1.Items.Add("Kevin")

        ComboBox1.SelectedIndex = 2 'will display Peter

        ComboBox1.Sorted = True

    End Sub


Please note after you sort your combobox, the SelectedIndex is reseted.


        ComboBox1.Sorted = True
        ComboBox1.SelectedIndex = 1 'will display Kevin



To access the selected text in the combobox, we use the text property.


        MsgBox(ComboBox1. Text)




If you are tempted to do some manipulations with the items in the combobox, keep in mind that combobox are collections. They use the same feature than regular collection.

To add:
Combobox1.items.add = "Obama"

To get the number of items:
Combobox1.items.count

To remove item according to its index in:
Combobox1.items.Remove (2), for example, to remove the second element of the collection


Reference :


Update Contact :
No Wa/Telepon (puat) : 085267792168
No Wa/Telepon (fajar) : 085369237896
Email : Fajarudinsidik@gmail.com
NB :: Bila Sobat tertarik Ingin membuat software, membeli software, membeli source code, membeli hardware elektronika untuk kepentingan Perusahaan maupun Tugas Akhir (TA/SKRIPSI), Insyaallah Saya siap membantu, untuk Respon Cepat dapat menghubungi kami, melalui :

No Wa/Telepon (puat) : 085267792168
No Wa/Telepon (fajar) : 085369237896
Email: Fajarudinsidik@gmail.com


atau Kirimkan Private messanger melalui email dengan klik tombol order dibawah ini :

ٱلْحَمْدُ لِلَّهِ رَبِّ ٱلْعَٰلَمِين
Alhamdulilah hirobil alamin

وَ السَّلاَمُ عَلَيْكُمْ وَرَحْمَةُ اللهِ وَبَرَكَاتُهُ
wassalamualaikum warahmatullahi wabarakatuh


Artikel How to use a combobox, Diterbitkan oleh scodeaplikasi pada Sabtu, 20 Oktober 2012. Semoga artikel ini dapat menambah wawasan Anda. Website ini dipost dari beberapa sumber, bisa cek disini sumber, Sobat diperbolehkan mengcopy paste / menyebar luaskan artikel ini, karena segala yang dipost di public adalah milik public. Bila Sobat tertarik Ingin membuat software, membeli software, membeli source code ,Dengan Cara menghubungi saya Ke Email: Fajarudinsidik@gmail.com, atau No Hp/WA : (fajar) : 085369237896, (puat) : 085267792168.

Tawk.to