DataTextField DropDownlist

  • Thread starter Thread starter Rafael Metring
  • Start date Start date
R

Rafael Metring

How set DAtaTextField and DataValueField in dropdOwnlist

I use this to populate..

Dim sqlConn As SqlCeConnection = Nothing

Dim dr As SqlCeDataReader

Dim da As SqlCeDataAdapter

Dim ds As DataSet = New DataSet

Dim strsql As String

Try

sqlConn = New SqlCeConnection("Data Source =\My Documents\multiseguros.sdf")

Dim insertCommand As SqlCeCommand = sqlConn.CreateCommand()

strsql = "select * from Produto"

sqlConn.Open()

da = New SqlCeDataAdapter(strsql, sqlConn)

da.Fill(ds)

lstProduto.DataSource = ds.Tables(0).DefaultView

lstProduto.Refresh()

Catch err As SqlCeException

MessageBox.Show(err.Message)

Finally

If sqlConn.State = ConnectionState.Open Then

sqlConn.Close()

End If

End Try
 
Rafael:
Rafael Metring said:
How set DAtaTextField and DataValueField in dropdOwnlist

I use this to populate..

Dim sqlConn As SqlCeConnection = Nothing

Dim dr As SqlCeDataReader

Dim da As SqlCeDataAdapter

Dim ds As DataSet = New DataSet

Dim strsql As String

Try

sqlConn = New SqlCeConnection("Data Source =\My Documents\multiseguros.sdf")

Dim insertCommand As SqlCeCommand = sqlConn.CreateCommand()

strsql = "select * from Produto"

sqlConn.Open()

da = New SqlCeDataAdapter(strsql, sqlConn)

da.Fill(ds)

lstProduto.DataSource = ds.Tables(0).DefaultView

lstProduto.Refresh()

Catch err As SqlCeException

MessageBox.Show(err.Message)

Finally

If sqlConn.State = ConnectionState.Open Then

sqlConn.Close()

End If

End Try

The .DisplayMember and .ValueMember fields are probably what you are looking
for
 
Use the DisplayMember and ValueMember properties of the ComboBox to define
which fields are to be displayed and used as the value member when
retrieving the user's selection:-
lstProduto.DisplayMember = "DisplayFieldName"
lstProduto.ValueMember = "ValueFieldName"

Where you substitute the fieldnames from your datasource.

Peter
 
Tanks willian and Petter

Rafael

Peter Foot said:
Use the DisplayMember and ValueMember properties of the ComboBox to define
which fields are to be displayed and used as the value member when
retrieving the user's selection:-
lstProduto.DisplayMember = "DisplayFieldName"
lstProduto.ValueMember = "ValueFieldName"

Where you substitute the fieldnames from your datasource.

Peter

--
Peter Foot
Windows Embedded MVP
OpenNETCF.org Senior Advisor
www.inthehand.com | www.opennetcf.org
 
Back
Top