B4A Library Grid/Table and ListView Library

This library allows to create easely grids/tables and
from version 2.50
list views too!

The original post has been moved

Version 2.50 beta
- Added support for multiline rows

Version 2.51 beta
- Bug fixes

Version 2.52 beta
- Added Typeface support for rows and hedaer

Version 2.53
- Added SingleLine property for columns

sample code and usage hints can be found here

Version 2.55
- Added object b4aActivityContext

Version 2.56
- Added and modified event hendlers

Version 2.57
- Added Columns Builders

Version 2.58
- Bug fixes

Version 2.59
- Added RowHeight for each column
- Added HeaderHeight for each column

Version 2.60
- Added TouchX() and TouchY()
- Added FirstVisiblePosition() and LastVisiblePosition()

Version 2.65
- Added Button Columns

Version 2.67
- Added CellProps event
- Removed PropSetColor / PropSetTextColor

Version 2.71
- Added OnSelectAllow event
- Added selection on row background

Version 2.73
- Added OnRowProps event

Version 2.76
- Fixed dubug log bug

If you like my grid.
You can support the development.



  • xnGridSample200beta.zip
    3.6 KB · Views: 2,070
  • xnGrid2xx_1.png
    77.2 KB · Views: 5,147
  • xnObjects267.zip
    75.7 KB · Views: 802
  • xnObjects272.zip
    87.2 KB · Views: 602
  • xnObjects273.zip
    87.5 KB · Views: 697
  • xnObjects276.zip
    87.2 KB · Views: 1,450
Last edited:


Active Member
Licensed User
Longtime User
Yust set the changed value in the grid
gg.SetValue ( aRow , aCol , aNewValue )
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.


Active Member
Licensed User
Longtime 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.


Active Member
Licensed User
Longtime User
On Select Allow Event
Now you can prevent row selection using the "On_Select_Allow" event.

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

aRow : the row number
aValues : the values of the row

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

Allow is set to true by default.
Last edited:


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

Sub gg_RowProps ( aRow As Int , aValues() As String , aProps As xnGridRowProps )
If aRow = 5 Then
   aProps.Height = 100dip
End If
End Sub

aRow : the row number
aValues : the values of the row

aProps : the row properties


Active Member
Licensed User
Longtime 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.


Active Member
Licensed User
Longtime User
good idea!
i've tryed to add freeze columns more than once
but i've not yet been able
may be it'll be the right time

David Hawkins

Active Member
Licensed User
Longtime User
Hi Stefano
is it possible to get the dimensions of the a cell that has been selected i.e. Top left position, width and height.



David Hawkins

Active Member
Licensed User
Longtime User
Hi Stefano

I am trying to put a tick in a column with this code but it appears not to work could you check it for me please as I am probably missing something.

private Sub LoadGrid

CLGrid.RowHeight = 15%y
CLGrid.HeaderHeight = 7%y
CLGrid.HeaderTextSize = 16
CLGrid.HeaderTextColor = Colors.White
CLGrid.HeaderTypeface = Typeface.DEFAULT_BOLD
CLGrid.HeaderColor = Colors.Black

Dim cc(3) As xnGridCol
cc(0).Initialize2 ("Test", "TEST", 15%x, Gravity.LEFT):CLGrid.ColAppend ( cc(0))
cc(1).Initialize2 ("Test1", "TEST1", 15%x, Gravity.LEFT):CLGrid.ColAppend ( cc(1))
cc(2).Initialize2 ("Test2", "TEST2", 15%x, Gravity.LEFT):CLGrid.ColAppend ( cc(2))

cc(0).RowIconTop = 2%y
cc(0).RowIconLeft = 2%x

cc(1).RowIconTop = 2%y
cc(1).RowIconLeft = 2%x

Activity.AddView (CLGrid, 0%x, 0%y, 45%x, 40%y)

CLGrid.RowAppend( Array As String("","1", ""))
CLGrid.RowAppend( Array As String("1","", "1"))

CLGrid.Visible = True
CLGrid.GridWidth = 1
CLGrid.PixelFix = False

End Sub

private Sub CLGrid_CellClick ( Col As Int , Row As Int )
Dim result As Int

result = Msgbox2("Please select Yes for a Tick", "", "Yes", "", "No", Null )

If result = DialogResponse.POSITIVE Then
CLGrid.SetValue(Row ,Col , "1")
CLGrid.SetValue(Row ,Col, "0")
End If

End Sub