Gambas-it

Gambas3 => Programmazione => Topic aperto da: doublemm - 28 Agosto 2011, 23:48:44

Titolo: [RISOLTO] no refresh con gridbox
Inserito da: doublemm - 28 Agosto 2011, 23:48:44
ciao a tutti, c'è qualche condizione per fare il refresh ad una gridbox? ho collegato una gridbox ad un db e tutto funziona. Se faccio un button con al suo interno nomegriglia.refresh() mi da errore null object.
Titolo: Re: no refresh con gridbox
Inserito da: milio - 29 Agosto 2011, 03:28:07
puoi postare un esempio dove ti si ricrea l'errore?
Titolo: Re: no refresh con gridbox
Inserito da: doublemm - 29 Agosto 2011, 12:00:06
Codice: [Seleziona]
Public Sub main(Conn As Connection)
 
  Dim Griglia As GridBox
  Dim LabelTipoAggio, LabelData, LabelImporto, LabelQt As Label
  Dim PSalva, PSisal, PGratta, PCirsa As Button
  Dim Immagine As PictureBox
  Dim sisal As Picture
 
  Griglia = New GridBox(Main1.FormPrincipale)
  LabelTipoAggio = New Label(Main1.FormPrincipale)
  LabelData = New Label(Main1.FormPrincipale)
  LabelImporto = New Label(Main1.FormPrincipale)
  LabelQt = New Label(Main1.FormPrincipale)
  Elenco1 = New ComboBox(Main1.FormPrincipale) As "Elenco1"
  PSalva = New Button(Main1.FormPrincipale) As "Psalva"
  PSisal = New Button(Main1.FormPrincipale) As "PSisal"
  PGratta = New Button(Main1.FormPrincipale) As "PGratta"
  PCirsa = New Button(Main1.FormPrincipale) As "PCirsa"
  TData = New DateBox(Main1.FormPrincipale) As "TData"
  TQt = New TextBox(Main1.FormPrincipale)
  Importo = New ValueBox(Main1.FormPrincipale)
  AreaGrafico = New PictureBox(Main1.FormPrincipale)
 
  Connessione = Conn
  If connessione.Opened = False Then connessione.Open
 
  With Griglia
    .Connection = connessione
    .x = 10
    .y = 10
    .w = Main1.FormPrincipale.w / 2
    .h = Main1.FormPrincipale.h / 2
  End With
 
  With Griglia.Columns[0]
    .Hide = False
    .Type = Grid.Type.Field
    .DataType = Grid.DataType.String
    .Field = "id"
    .Text = "ID"
    .Name = "id"
    .Required = True
    .w = 10
    .Alignment = 3
  End With
 
  With Griglia.Columns[1]
    .Hide = False
    .Type = Grid.Type.Field
    .DataType = Grid.DataType.String
    .Field = "data"
    .Text = "DATA"
    .Name = "data"
    .Required = True
    .w = 10
    .Alignment = 3
  End With
 
  With Griglia.Columns[2]
    .Hide = False
    .Type = Grid.Type.Field
    .DataType = Grid.DataType.String
    .Field = "descrizione"
    .Text = "DESCRIZIONE"
    .Name = "descrizione"
    .Required = True
    .w = 10
    .Alignment = 3
  End With
 
  With Griglia.Columns[3]
    .Hide = False
    .Type = Grid.Type.Field
    .DataType = Grid.DataType.String
    .Field = "qt"
    .Text = "QT"
    .Name = "qt"
    .Required = True
    .w = 10
    .Alignment = 3
  End With
 
  With Griglia.Columns[4]
    .Hide = False
    .Type = Grid.Type.Field
    .DataType = Grid.DataType.String
    .Field = "aggio"
    .Text = "AGGIO"
    .Name = "aggio"
    .Required = True
    .w = 10
    .Alignment = 3
  End With
 
  With Griglia
    .Expand = True
    .Color.RowAlternating = Color.RGB(230, 230, 230)
    .AutoDataType = True
    .MonitoringSave = True
    .GridOnly = True
    .TableName = "AGGI"
    .LoadData("SELECT id,data,descrizione,qt,aggio FROM AGGI ORDER BY data DESC")
    .ColorRowAlternating = True
    .AlwaysEditable = False
    .ReadOnly = False
    .AutoNew = True
    .AlignmentHeader = 3
    .Columns[0].W = ((Griglia.W - Griglia.Rows.w) / 100) * 10
    .Columns[1].W = ((Griglia.W - Griglia.Rows.w) / 100) * 20
    .Columns[2].W = ((Griglia.W - Griglia.Rows.w) / 100) * 40
    .Columns[3].W = ((Griglia.W - Griglia.Rows.w) / 100) * 10
    .Columns[4].W = ((Griglia.W - Griglia.Rows.w) / 100) * 10
  End With
 
  With LabelData
    .Text = "DATA"
    .h = Desktop.h / 32.92
    .w = (((Desktop.w - LabelData.x) / 2) - 15) / 3
    .x = Griglia.X + Griglia.w + 10
    .y = Griglia.y
    .Font.size = 10
  End With
 
   With TData
    .Font.size = 10
    .h = LabelData.H
    .W = 15 * TData.Font.TextWidth("0")
    .x = LabelData.X
    .y = LabelData.y + LabelData.H + 5   
  End With
 
   With LabelTipoAggio
    .Text = "TIPO AGGIO:"
    .h = LabelData.H
    .w = TData.W
    .x = TData.x + TData.w + 10
    .y = LabelData.y
    .Font.size = 10
  End With
 
    With Elenco1
    .Font.Size = 10
    .x = TData.X + TData.w + 10
    .y = TData.Y
    .w = Main1.FormPrincipale.w - Elenco1.x - 10
    .h = LabelTipoAggio.H
    .Show
  End With
 
   With LabelQt
    .Font.size = 10
    .Text = "QT"
    .h = LabelTipoAggio.h
    .w = 30
    .x = LabelData.x
    .y = TData.y + TData.h + 10 
  End With
 
  With TQt
    .h = LabelQt.H
    .W = TData.w / 3
    .x = LabelQt.X
    .y = LabelQt.y + LabelQt.h + 5
    .Font.size = 10
  End With
 
  With LabelImporto
    .Font.size = 10
    .Text = "IMPORTO"
    .h = LabelData.h
    .w = LabelData.w
    .x = TQt.X + TQt.W + 10
    .y = LabelQt.y
  End With
 
  With Importo
    .x = TQt.x + TQt.w + 10
    .y = TQt.y
    .w = (TData.x + TData.w) - LabelImporto.X
    .h = TData.h
    .Font.size = main1.FormPrincipale.w / 130
  End With   
 
  With PSalva
    .Text = "SALVA"
    .h = TQt.H
    .w = Importo.W
    .x = Importo.x + Importo.w + 10
    .y = Importo.y
    .Font.size = 10
    .Picture = Image.Load("Immagini/salva.png").Stretch(PSalva.h - 3, PSalva.h - 3).Picture
  End With
 
   With PSisal
    .x = Griglia.X
    .y = Griglia.y + Griglia.h + 10
    .h = PSalva.H * 2
    .w = PSisal.h
  End With
 
  With PGratta
    .x = PSisal.X
    .y = PSisal.y + PSisal.h + 10
    .h = PSalva.H * 2
    .w = PSisal.h
  End With
 
  With PCirsa
    .x = PGratta.X
    .y = PGratta.y + PGratta.h + 10
    .h = PSalva.H * 2
    .w = PSisal.h
  End With
 
  sisal = Picture.Load("Immagini/sisal.jpg")
  sisal = sisal.Image.Stretch(PSisal.w, PSisal.h).Picture
  PSisal.Picture = sisal
 
  sisal = Picture.Load("Immagini/gratta.jpeg")
  sisal = sisal.Image.Stretch(PSisal.w, PSisal.h).Picture
  PGratta.Picture = sisal
 
  sisal = Picture.Load("Immagini/cirsa.jpeg")
  sisal = sisal.Image.Stretch(PSisal.w, PSisal.h).Picture
  PCirsa.Picture = sisal
 
   With AreaGrafico
    .x = PSisal.x + PSisal.w + 10
    .y = PSisal.Y
    .w = main1.FormPrincipale.w - PSisal.x - PSisal.w - 20
    .h = main1.FormPrincipale.h - AreaGrafico.y - 30
    .Show()   
  End With
 
  CreaElenco1()
  grafico1()
 
End

Public Sub PSisal_Click()
 
    Griglia.Refresh()
   
End
Titolo: Re: no refresh con gridbox
Inserito da: doublemm - 29 Agosto 2011, 18:52:02
mi sono accorto da solo che c'è un problema di doppia dichiarazione di gridbox ora funziona tutto