B4A Library Grid/Table and ListView Library

Discussion in 'Additional libraries, classes and official updates' started by stefanobusetto, Mar 28, 2012.

  1. aviario

    aviario Active Member Licensed User

  2. magi6162

    magi6162 Well-Known Member Licensed User

    1.when I edit table data in the database , how do I update the data in the grid using grd.cursorappend ( c ) ?
    2.the grid is ok, but the column "Mia" don't see the bitmap.(see code)

    Code:
    grd.Initialize("grd")
        c = Main.PTalk.ExecQuery(
    "SELECT Nome,Giorno,OrarioT,Tel,Resp,TelResp,Via,Citta,Lingua,Lat,Lon,Alt,Mia,IDC FROM Congregazioni ORDER BY Nome")

        bmpCheckTrue.Initialize ( 
    File.DirAssets,"ic_action_spunta.png" )

        sc = grd.ColCreateAndAppend2(
    "Nome",        "Nome",100dip,Gravity.LEFT + Gravity.CENTER_VERTICAL)
        sc = grd.ColCreateAndAppend2(
    "Giorno",        "Giorno",75dip,Gravity.CENTER_VERTICAL + Gravity.LEFT)
        
        sc = grd.ColCreateAndAppend2(
    "Mia",    "Mia",35dip,Gravity.CENTER_HORIZONTAL + Gravity.CENTER_VERTICAL)
        sc.RowIconLeft = TalkCode.cRowIconLeft
        sc.RowIconTop  = TalkCode.cRowIconTop
        sc.SetTypeImage
        sc.RowIconPut(
    "1",bmpCheckTrue)
        sc = grd.ColCreateAndAppend2(
    "IDC",        "IDC",0dip,Gravity.CENTER_VERTICAL + Gravity.LEFT)

        grd.CursorAppend(c)
       
        c.Close
       
        grd.HeaderTextSize = TalkCode.cHeaderTextSize
        grd.HeaderHeight = TalkCode.cHeaderHeight
        grd.RowTextSize = TalkCode.cRowTextSize
        grd.RowTextColor = 
    Colors.RGB(TalkCode.cGridColor(0),TalkCode.cGridColor(1),TalkCode.cGridColor(2))
        grd.RowHeight = TalkCode.cRowHeight
        grd.GridColor = 
    Colors.RGB(TalkCode.cGridColor(0),TalkCode.cGridColor(1),TalkCode.cGridColor(2))
        grd.GridWidth = TalkCode.cGridWidth
        grd.HeaderColor = 
    Colors.RGB(TalkCode.cHeaderColor(0),TalkCode.cHeaderColor(1),TalkCode.cHeaderColor(2))
        grd.HeaderTextColor = 
    Colors.RGB(TalkCode.cHeaderTextColor(0),TalkCode.cHeaderTextColor(1),TalkCode.cHeaderTextColor(2))
        grd.RowEvenColor = 
    Colors.RGB(TalkCode.grdRowEvenColor(0),TalkCode.grdRowEvenColor(1),TalkCode.grdRowEvenColor(2))          
        grd.RowOddColor = 
    Colors.RGB(TalkCode.grdRowOddColor(0),TalkCode.grdRowOddColor(1),TalkCode.grdRowOddColor(2))          
        grd.SelectedEvenColor = 
    Colors.RGB(TalkCode.grdSelectedEvenColor(0),TalkCode.grdSelectedEvenColor(1),TalkCode.grdSelectedEvenColor(2))          
        grd.SelectedOddColor = 
    Colors.RGB(TalkCode.grdSelectedEvenColor(0),TalkCode.grdSelectedEvenColor(1),TalkCode.grdSelectedEvenColor(2))          
       
        pnlGrid.AddView ( grd , 
    0 , 0 , pnlGrid.Width, pnlGrid.Height)
        grd.GridCreate
     
  3. stefanobusetto

    stefanobusetto Active Member Licensed User

    May you post a small b4a example project?
    :)
     
  4. magi6162

    magi6162 Well-Known Member Licensed User

    I resolved for 2 (error path bitmap)
    but when I edit table data in the database, how do I update the data in the grid using grd.cursorappend ( c )
    (in italiano: quando modifico dei valori dei campi del database , come posso far aggiornare la griglia relativa a quei dati?
    (senza dover ricrearla ex-novo, se possibile)
     
  5. stefanobusetto

    stefanobusetto Active Member Licensed User

    Yust set the changed value in the grid
    gg.SetValue ( aRow , aCol , aNewValue )
    or
    gg.SetValue2 ( aRow , aColName , aNewValue )
    where aRow and aCol are the row index and the column index
    and aNewValue is the new value for the cell.
    You can use the column name too (SetValue2 ).
    Or you can replace all the values of a row with the
    SetValues method.
    You have also the gg.SetValueSafe and gg.SetValueSafe2
    methods. These methods also checks the ranges of the
    parameters passed.
    No need to recreate or even refresh the grid.
    :)
     
  6. magi6162

    magi6162 Well-Known Member Licensed User

    thanks ... i'll try
     
  7. qsrtech

    qsrtech Active Member Licensed User

    I'm not sure if it's posted here anywhere but I just want to post a tip about scrolling rows in case someone else runs into it. I've found that you need do the "Scroll" after selecting a row, so if you want to select the row you're scrolling to you need to do it after you scroll and not before, otherwise it will not scroll to it.
     
  8. stefanobusetto

    stefanobusetto Active Member Licensed User

    On Select Allow Event
    Now you can prevent row selection using the "On_Select_Allow" event.

    Code:
    Sub gg_on_select_allow ( aRow As Int , aValues() As String , aOnSelect As xnGridOnSelect )
    Log ( "on select allow" )
    If aRow = 2 Then
       aOnSelect.Allow = 
    False
    End If
    End Sub
    Parameters
    aRow : the row number
    aValues : the values of the row

    aOnSelect : the selection options ( only allow true/false for now )

    Note
    Allow is set to true by default.
     
    Last edited: Jun 26, 2015
  9. stefanobusetto

    stefanobusetto Active Member Licensed User

    thanks to imgchiaram
    who helped me to develop
    the last release
     
    imgsimonebiliato likes this.
  10. stefanobusetto

    stefanobusetto Active Member Licensed User

    On Row Props Event
    Can be used to set the properties of each row (height for now).

    Code:
    Sub gg_RowProps ( aRow As Int , aValues() As String , aProps As xnGridRowProps )
    If aRow = 5 Then
       aProps.Height = 
    100dip
    End If
    End Sub
    Parameters
    aRow : the row number
    aValues : the values of the row

    aProps : the row properties
     
    qsrtech likes this.
  11. aviario

    aviario Active Member Licensed User

    thank you very much
     
  12. magi6162

    magi6162 Well-Known Member Licensed User

    how can I change color to the entire row?
    I think use cellprops event, but i don't know how do it.

    Code:
    Sub grdI_CellProps ( aCol As Int , aRow As Int , aValue As String , aProps As xnGridCellProps )
      
        
    If aCol = 13 Then   'aCol = 13  width = 0  invisible
            Dim diff As Double
            diff = 
    DateTime.Now - mv.Get(aValue)
            
    If diff <= 3 Then
                
    ' color entire row   <<<<--------------------------- here
                              .....

    .........
    End Sub
    Help me please
    thanks
     
    Last edited: Jul 30, 2015
  13. stefanobusetto

    stefanobusetto Active Member Licensed User

    Code:
    If aRow = 1 Then
      aProps.BackGroundColor = 
    Colors.Green
    End If
     
  14. magi6162

    magi6162 Well-Known Member Licensed User

    thank you
     
  15. qsrtech

    qsrtech Active Member Licensed User

    Do you think it possible for you to add a pinch to zoom feature? Essentially I think it would just be an algorithm to increase/decrease the font/column size.
     
  16. stefanobusetto

    stefanobusetto Active Member Licensed User

    Sorry
    i don't think so
    :)
     
  17. magi6162

    magi6162 Well-Known Member Licensed User

    i use 2.73 all ok, but in Log (when use grd.RowAppend( )) result this:
    you've forgotten a log in code ?
     
  18. DonManfred

    DonManfred Expert Licensed User

    One? Five! :D
     
  19. stefanobusetto

    stefanobusetto Active Member Licensed User

  20. stefanobusetto

    stefanobusetto Active Member Licensed User

    Removed debug log
    :)
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice