B4A Library Grid/Table and ListView Library

BluSky76

Member
Licensed User
Thanks for the reply.

I do not want to delete a single line but with a command to delete all selected rows. If the grid contains 100 rows and 20 are selected I want to delete a command only the twenty selected.

example
grid.RowDeleteSelect

Thank you
 

Sberla

Active Member
Licensed User
Hello !
Is it possible to set the textcolor and of text size of columns instead of rows ?

Thanx
 

stefanobusetto

Active Member
Licensed User
Use the "CellProps" event
:)

B4X:
Sub gg_CellProps ( aCol As Int , aRow As Int , aValue As String , aProps As xnGridCellProps )
If aCol = 1 Then
   aProps.TextColor = Colors.Red
   aProps.BackGroundColor = Colors.Gray
End If

If aCol = 1 Then
   If aRow = 1 Then
      aProps.BackGroundColor = Colors.Green
   End If
End If
End Sub
 

GaryK4

Member
Licensed User
Use the "CellProps" event
:)

B4X:
Sub gg_CellProps ( aCol As Int , aRow As Int , aValue As String , aProps As xnGridCellProps )
If aCol = 1 Then
   aProps.TextColor = Colors.Red
   aProps.BackGroundColor = Colors.Gray
End If

If aCol = 1 Then
   If aRow = 1 Then
      aProps.BackGroundColor = Colors.Green
   End If
End If
End Sub
I am new to this library. It looks very promising.
I created a test program and the CellProps event is giving a java error.
"java.lang.IllegalStateException: This method must only be called as part of a callback while a frame is in progress."

My phone is a new Note 8 - Android 7.1.1

What I am trying to accomplish is as follows,
When I long click a row or based on a db record, set that row to a color.
The original SetPropColor would have been perfect for my needs.

-----------------
I changed the program from GridCreate2(False) to GridCreate and the java error went away.
Now, I can get it to do what I want.
-----------------
 
Last edited:

GaryK4

Member
Licensed User
Sorry,
could you list a list of all the grid events?

thanks
Hi,

I am just in the evaluation process. The current events are select, long_select and CellProps.

As I said in my edited message, I got the program to work.
GridCreate2(False) was creating a java error.
GridCreate works!

I'm not sure what the difference is, but I will go with what is working.
 

stefanobusetto

Active Member
Licensed User
The horizontal and vertical scroll bars are automatically display.
You can enable the FastScroll option
B4X:
Grid.FastScroll = True ;
:)
 

GaryK4

Member
Licensed User
I added the following code to the provided sample program.

Sub gg_CellProps ( aCol As Int , aRow As Int , aValue As String , aProps As xnGridCellProps )
Log (aCol & " - " & aRow)
End Sub

There are 3 rows with 4 columns.
When I touch a cell, It lists all rows and columns. Not just the one that I selected?

Am I doing something wrong?
 

stefanobusetto

Active Member
Licensed User
The CellProps is called every time a cell is painted.
You can set the cell properties assigning vaules to the aProps object.
The aCol , aRow and aValue are passed to provide information on the
painting cell.
What do you want to do?
:)
 

GaryK4

Member
Licensed User
The CellProps is called every time a cell is painted.
You can set the cell properties assigning vaules to the aProps object.
The aCol , aRow and aValue are passed to provide information on the
painting cell.
What do you want to do?
:)
I want to long click on a cell and change it value and background color. Basically, a toggle column.
 

imgsimonebiliato

Well-Known Member
Licensed User
how to set the color of a row based on the value of one column?
Hi @jrat you need to implement this method:


B4X:
Dim grid as xnGrid

Sub grid_CellProps ( aCol As Int, aRow As Int, aValue As String, aProps As xnGridCellProps )
Dim v As String
v = grid.GetValue2 ( aRow, "VALUE" )

If v = "0" Then aProps.BackGroundColor = Colors.Red
If v = "1" Then aProps.BackGroundColor = Colors.Green

End Sub
 
Top