[Gambas-user] Create and delete labels dinamically

Caveat Gambas at ...1950...
Mon Jun 27 12:15:40 CEST 2011


Private allLabels as TextLabel[]

Public Sub Test_Click()

  allLabels = New TextLabel[10]
  createLabels()
  deleteLabels()
  tidyLabels()
  
End

Public Sub createLabels()
  
  Dim idx As Integer
 
  For idx = 0 To 9
    allLabels[idx] = New TextLabel(Me)
    allLabels[idx].X = 10
    allLabels[idx].Y = 10 + (idx * 22)
    allLabels[idx].Width = 450
    allLabels[idx].Height = 20
    allLabels[idx].Tag = idx
    allLabels[idx].Text = "I am label " & idx
  Next

End
  
Public Sub deleteLabels()
  
  allLabels[3].Delete
  allLabels[8].Delete
 
End

Public Sub tidyLabels()
  
  Dim aLabel As TextLabel
  Dim idx, idy As Integer
  For idx = 0 To allLabels.length - 1
    If Object.IsValid(allLabels[idx]) Then
      allLabels[idx].Y = 10 + (idy * 22)
      Inc idy
    End If
  Next

End

Regards,
Caveat

On Mon, 2011-06-27 at 11:41 +0200, M. Cs. wrote:
> I know how to create a label object with the
> myLabel=New Label(Fmain) sentence. But how could I create an array of
> labels in order to be able to remove them if needed?
> 
> ------------------------------------------------------------------------------
> All of the data generated in your IT infrastructure is seriously valuable.
> Why? It contains a definitive record of application performance, security 
> threats, fraudulent activity, and more. Splunk takes this data and makes 
> sense of it. IT sense. And common sense.
> http://p.sf.net/sfu/splunk-d2d-c2
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user






More information about the User mailing list