con VB.NET:
per raccogliere 2 valori quali l'ID e il testo, con una ComboBox() ho usato la classe "MyListItem"
in questo modo:codice:Public Class MyListItem Private m_id As Long Private m_text As String Public Overrides Function ToString() As String Return m_text End Function Public Sub New(ByVal Text As String, ByVal Value As Long) m_text = Text m_id = Value End Sub Public Property Value() As Long Get Return m_id End Get Set(ByVal Value As Long) m_id = Value End Set End Property Public Property Text() As String Get Return m_text End Get Set(ByVal Value As String) m_text = Value End Set End Property End Class
e raccolgo i dato in questo modo:codice:'popolo la ComboBox() Categorie conn.Open() Dim sql As String = "SELECT * FROM Categorie" Dim comm As New OleDbCommand(sql, conn) Dim read As OleDbDataReader = comm.ExecuteReader While read.Read() cmbCat.Items.Add(New ListItem(read("Cat"), read("Id").ToString)) End While conn.Close()
ma se voglio gestire tre valori invece che due come posso fare???codice:Dim Item As MyListItem = cmbCat.SelectedItem Dim ID As Integer = Item.Value Dim Categoria As String = Item.Text
i tre campi da gestire
ID = integer
Cat = string
IDC = integer
la mia tabella:
ID -- Cat -- IDC

Rispondi quotando