We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Add a new empty row in bind combo

Hi; I have a ComboBox (VS 2003) linked to DataSet; but I need add a new empty row (on the top) for select nothing.

How can I make this?

Thanks

1 Reply

ES Esteban October 25, 2006 05:49 AM UTC

OK, I found the answer. It's this (if someone is insteresting):

Private Sub FillComboAgentes()
Dim list As New DataTable
Dim DRow As DataRow
Dim X As Int16 = 1

list.Columns.Add(New DataColumn("Nombre", GetType(String)))
list.Columns.Add(New DataColumn("AgenteID", GetType(Integer)))
list.Rows.Add(list.NewRow())
list.Rows(0)(0) = "--- Ninguno ---" '
list.Rows(0)(1) = DBNull.Value

For Each DRow In TargeDS.Agentes
list.Rows.Add(list.NewRow())
list.Rows(X)(0) = DRow("Nombre") & " " & DRow("Apellidos")
list.Rows(X)(1) = DRow("AgenteID")
X += 1
Next

C_Agentes.DataSource = list
C_Agentes.DisplayMember = "Nombre"
C_Agentes.ValueMember = "AgenteID"
End Sub

Loader.
Live Chat Icon For mobile
Up arrow icon