How to Get Value Member in a ListBox Using C# and SQL Server



In this tutorial, I’m going to teach you how to get the value member in a Listbox using C# and SQL Server. Listbox is a control window that contained a list of items where it allows the user to choose one or more items. For instance, if you want to display the list of Books in the Listbox from the database but it’s the id that you only want to display. It’s the time to use the value member for getting the id of the employees in the ListBox.


Database : Click here for the database of this project.

Let’s begin:


Open Microsoft Visual Studio and create a new windows application for C#. Then, do the form just like this.


After setting up the form, go to the solution explorer and hit “code view” to fire the code editor.


In the code editor, declare all the classes and variable that are needed.

Note: Put “using System.Data.SqlClient;” above the namespace to access sql server library.

After that, create a method for filling data in the list control of a ListBox.

Go back to the design view, double-click the form and do the following codes to establish the connection between SQL Server 2005 Express Edition and

Go back to the design view again, click a ListBox and go to properties. In the properties, hit the events, just like a lightning symbol and select click for the events.


after that, do the following codes for getting the value member of a ListBox when selected.



For all students who need a programmer for your thesis system or anyone who needs a source code in any a programming languages. You can contact me @ :



Email – [email protected]
Mobile No. – 09305235027 – TNT


Looking for more source code? Type your keyword here here!


Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.