B4A Library Grid/Table and ListView Library

stefanobusetto

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

qsrtech

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.
 

stefanobusetto

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

B4X:
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:

stefanobusetto

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

B4X:
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

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.
 

stefanobusetto

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.

Regards

David
 

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.Initialize("CLGrid")
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(0).setTypeCheck

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

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

CLGrid.GridCreate2(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")
Else
CLGrid.SetValue(Row ,Col, "0")
End If

End Sub
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…