Gambas-it

Gambas dal mondo esterno => Germania => Topic aperto da: vuott - 06 Agosto 2024, 18:09:07

Titolo: Assegnare parti di testo, avente struttura costante, in una GridView
Inserito da: vuott - 06 Agosto 2024, 18:09:07
https://www.gambas-club.de/viewtopic.php?t=6023
Titolo: Re:Assegnare parti di testo, avente struttura costante, in una GridView
Inserito da: Gianluigi - 06 Agosto 2024, 23:45:14
Io lo farei così:
Codice: [Seleziona]
'' gb.util need

Private hGrid As GridView

Public Sub Form_Open()

  With Me
    .H = 360
    .W = 400
    .Arrangement = Arrange.Vertical
    .Margin = True
  End With
  With hGrid = New GridView(Me)
    .Expand = True
    .Header = GridView.Both
    .Columns.Count = 3
    .Columns[0].Text = "DATUM"
    .Columns[0].Width = 120
    .Columns[1].Text = "PRODUKT"
    .Columns[1].Width = 120
    .Columns[2].Text = "PREIS"
  End With
  UpPriceList

End

Private Sub UpPriceList()

  Dim hList As CsvFile
  Dim cList As Collection
  Dim i As Integer
  Dim s, sPath As String

  sPath = "./output.txt"
  hList = New CsvFile(sPath, "|") ' opens in reading
  While Not hList.Eof
    hGrid.Rows.Count += 1
    cList = hList.Read()
    hGrid[i, 0].Text = cList!Datum
    hGrid[i, 1].Text = cList!Produkt
    hGrid[i, 2].Text = cList!Preis
    Inc i
  Wend
  hList.Close

End
Dimenticavo di allegare il file di testo che deve mostrare/avere le intestazioni...