How to add items to dropdown from database or any other datasource - Bunifu Framework | Empowering software developers craft great user experiences in less time. Productivity tools for C# & VB.NET UX/UI design

How to add items to dropdown from database or any other datasource

flat vertical and horizontal scroll bars
How to customize a Flow Layout Panel with Bunifu’s beautiful Scroll Bars
May 21, 2018
Achieve beautiful dashboard panels in your project using shadow panel
June 29, 2018
Show all

How to add items to dropdown from database or any other datasource

Adding items to drop down from a database

BunifuDropdown comes with a lot of flexibility in terms of UI and also the functionality,  to achieve the below designs you can head to the properties window and customize to the best you can. Judging from the title of this post I trust you are well familiar on how to add a control to toolbox if not please refer here. Let’s get started.

Adding items to BunifuDropdown can be implemented using the Form designer and also from code.

Adding from the designer

  • Select BunifuDropdown and Right click -> Select Properties -> Identify Items property

  • Click the .. button and enter your items as below.
  • Click okay to save and you are good to go.

Adding from code

BunifuDropdown accepts collections that includes Lists, Arrays, etc that means we can add items from any source as long as it is a collection.

  • Adding from and array

C#

VB

  • Adding from a List

C#

VB

Note : Instead of looping through the collection you can simply write:

  • Adding from a Dictionary

C#

VB

  • Adding from a Model

C#

VB

Adding data from Mysql database

After knowing all the above now we can pull data from the database, below is the sample code

C#

VB

That’s about it.

Please find the attached source code for reference

Source

Cheers!

Amos Chepchieng
Amos Chepchieng
Software Developer, Bunifu Framework

1 Comment

  1. Mactuz says:

    is there any way, can we make it editable?

Leave a Reply

Your email address will not be published. Required fields are marked *