lucas22f ha scritto:
Stavo già guardando a qualche codice, ora lo inserisco pero la listview rimane bianca o mi da l'errore "system.indexoutofrangeexception" nella riga " lvi.SubItems.Add(reader("DORS"))"
Dim PercorsoApp
Dim NomeFile
Dim Path As String
Dim PathDB As String
NomeFile = Main.Status_IDGARA.Text
PercorsoApp = My.Application.Info.DirectoryPath
PathDB = PercorsoApp & "\Dati\Database\" & NomeFile & ".mdb"
Dim CON As New OleDb.OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source =" & PathDB)
CON.Open()
Dim Query_Select As String = "SELECT ID, ATLETA, LICENZA, CAT, NOMESOC, CODSOC, SESSO FROM Iscritti"
Dim cmd As OleDbCommand = New OleDbCommand(Query_Select, CON)
Dim reader As OleDbDataReader = cmd.ExecuteReader()
Dim lvi As New ListViewItem
ListView1.View = View.Details 'FONDAMENTALE'
ListView1.LabelEdit = True
ListView1.AllowColumnReorder = True
ListView1.FullRowSelect = True
ListView1.GridLines = True 'mostra una sottile griglia'
ListView1.Sorting = SortOrder.Ascending 'ordinamento'
ListView1.Columns.Add("ID", 70, HorizontalAlignment.Left)
ListView1.Columns.Add("DORSALE", 70, HorizontalAlignment.Left)
ListView1.Columns.Add("NOME E COGNOME", 300, HorizontalAlignment.Left)
ListView1.Columns.Add("LICENZA N°", 100, HorizontalAlignment.Left)
ListView1.Columns.Add("CATEGORIA", 70, HorizontalAlignment.Left)
ListView1.Columns.Add("SOCIETA'", 300, HorizontalAlignment.Left)
ListView1.Columns.Add("COD. SOCIETA'", 100, HorizontalAlignment.Left)
ListView1.Columns.Add("SESSO", 70, HorizontalAlignment.Left)
Do While reader.Read()
lvi = ListView1.Items.Add(reader("ID"))
lvi.SubItems.Add(reader("DORS"))
lvi.SubItems.Add(reader("ATLETA"))
lvi.SubItems.Add(reader("LICENZA"))
lvi.SubItems.Add(reader("CAT"))
lvi.SubItems.Add(reader("NOMESOC"))
lvi.SubItems.Add(reader("CODSOC"))
lvi.SubItems.Add(reader("SESSO"))
Loop
CON.Close()
End Sub
a memoria, ma molto a memoria, credo che la SubItems voglia l'index :
lvi.SubItems(0).Add(reader("DORS"))
lvi.SubItems(1).Add(reader("ATLETA"))
lvi.SubItems(2).Add(reader("LICENZA"))
lvi.SubItems(3).Add(reader("CAT"))
lvi.SubItems(4).Add(reader("NOMESOC"))
lvi.SubItems(5).Add(reader("CODSOC"))
lvi.SubItems(6).Add(reader("SESSO"))