VB.Net Populate Combobox From Text File

How To Bind A ComboBox With Values From Text File Using Visual Basic .Net

Populate Combobox From Text File Using VB.Net



In this VB.NET Tutorial we will see How To Import And Display Data From a Text File to a Combobox Using File.ReadAllLines() To Return An Array Of String In Visual Basic.Net   Programming Language And Visual  Studio Editor.




Project Source Code:


Imports System.IO

Public Class TXT_To_COMBO

    Private Sub TXT_To_COMBO_Load(sender As Object, e As EventArgs) Handles MyBase.Load
         
        ' get and read all lines from the text file
        ' return an array of string
        Dim lines() As String = File.ReadAllLines("C:\Users\1BestCsharp\Desktop\table2.txt")

        ' set lines as datasource
        ComboBox1.DataSource = lines

    End Sub
End Class


OutPut:

Fill Combobox From TXT File Using VB.Net




Share this

Related Posts

Previous
Next Post »