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.
Unfortunately, activation email could not send to your email. Please try again.

Add a new empty row in bind combo

Thread ID:

Created:

Updated:

Platform:

Replies:

50940 Oct 24,2006 04:16 AM Oct 25,2006 01:49 AM Windows Forms 1
loading
Tags: FAQ
Esteban
Asked On October 24, 2006 04:16 AM

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

Esteban
Replied On October 25, 2006 01:49 AM

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

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;