B4J Library [B4X] [XUI] SD FlexGrid (Table)

Sabotto

Well-Known Member
Licensed User
only this:
B4X:
FlexGrid1.SetCellCustomize (r, c, xui.Color_Green, xui.Color_Yellow, xui.CreateDefaultBoldFont (16))
I have tryed

B4X:
for i = 0 to 100
     FlexGrid1.SetCellCustomize(i,3,xui.Color_Blue,xui.Color_Yellow,xui.CreateDefaultBoldFont(16))
next i

Sub FlexGrid1_CellClick(Row As Int, Col As Int)
   Select FlexGrid1.GetTypeCol(Col)
   Case FlexGrid1.TypeCheck
      Dim B As Boolean = FlexGrid1.GetCellValue(Row,Col)
          
      If B Then
          FlexGrid1.SetCellCustomize(Row,3,xui.Color_Red,FlexGrid1.GetCellBackgroundColor(Row,Col),FlexGrid1.GetCellTextFont(Row,Col))
      Else
          FlexGrid1.SetCellCustomize(Row,3,xui.Color_Blue,FlexGrid1.GetCellBackgroundColor(Row,Col),FlexGrid1.GetCellTextFont(Row,Col))
      End If

but GetCellBackgroundColor does not return the code of xui.Color_Yellow. What is it for then?
 

Sabotto

Well-Known Member
Licensed User
I would have found another small bug. But give me confirmation if you like me to point them out or not. I don't want to bother you. In practice, if I choose to select the entire row, every time I touch any cell, at the second touch on the same cell, instead of making only that row remain selected, it also selects the one immediately below.

B4X:
Sub FlexGrid1_CellClick(Row As Int, Col As Int)
   
    FlexGrid1.SelectRow(Row)
   
    'if I double click on the same cell,
    'the right row and the one below are selected (two rows!)
   
    Select FlexGrid1.GetTypeCol(Col)
        Case FlexGrid1.TypeInt
            Dim I As String = FlexGrid1.GetCellValue(Row,Col)
            Log("Cell content: " & I)

furthermore by selecting the entire row, if I click on a checkbox, the second click (the check should reappear) is no longer taken into consideration and the check no longer appears
 
Last edited:

Star-Dust

Expert
Licensed User
Longtime User

It works for me. I used this code
B4X:
    FlexGrid1.SetCellCustomize(0,3,xui.Color_Black,xui.Color_Cyan,xui.CreateDefaultBoldFont(16))
    For I=0 To 9
        FlexGrid1.SetCellCustomize(i,1,xui.Color_Blue,xui.Color_Yellow,xui.CreateDefaultBoldFont(16))
    Next
   
    LogColor("Color" ,FlexGrid1.GetCellBackgroundColor(1,1))

Here is the result
 

Star-Dust

Expert
Licensed User
Longtime User
It works for me. Make sure you are not using ActiveCheckBox, it is no longer needed in version 0.09

Obviously, until it completes the display of the views it does not enable events.
 

Sabotto

Well-Known Member
Licensed User
As soon as you have time, take a look at this simple example.
I added a line of code to make sure that when I click on a checkbox, it changes the color of the text of the beside cell (column 1) If true: red; if false: blue.
But it doesn't keep the background color!

Also with each tap, I would like the entire row to be selected.
But if you de-COMMENT the instruction
B4X:
FlexGrid1.SelectRow (Row)
you will see that after clicking on a checkbox, if you click again on the same checkbox, not only does the checkbox no longer react, but two lines are selected.
 

Attachments

  • Test Flexgrid di StarDust.zip
    124.2 KB · Views: 330

Star-Dust

Expert
Licensed User
Longtime User
Dear friend,

You made a programming mistake. The color retains it, only you are transferring the background color of the wrong box.

Replace this
B4X:
If B Then
    FlexGrid1.SetCellCustomize(Row,1,xui.Color_Red,FlexGrid1.GetCellBackgroundColor(Row,Col),xui.CreateDefaultBoldFont(16))
Else
    FlexGrid1.SetCellCustomize(Row,1,xui.Color_Blue,FlexGrid1.GetCellBackgroundColor(Row,Col),xui.CreateDefaultBoldFont(16))
End If
with this
B4X:
If B Then
    FlexGrid1.SetCellCustomize(Row,1,xui.Color_Red,FlexGrid1.GetCellBackgroundColor(Row,1),xui.CreateDefaultBoldFont(16))
Else
    FlexGrid1.SetCellCustomize(Row,1,xui.Color_Blue,FlexGrid1.GetCellBackgroundColor(Row,1),xui.CreateDefaultBoldFont(16))
End If

I used your source code, with the fix mentioned
 
Last edited:

Star-Dust

Expert
Licensed User
Longtime User
Dear friend,

Here in my opinion you are making a mistake of use.

 

Sabotto

Well-Known Member
Licensed User
quite right. I apologize for the distraction. Regards the selection of the row, I do want select the row not the column (as in your gif)
Tap only on a single cell.
The row is selected and is ok
Another tap on the same cell, select the next row!
Is normal?
thanks for your time
 

Star-Dust

Expert
Licensed User
Longtime User
I have done several tests, it is not something that always happens. It is probably related to some aspects related to compatibility with iOs. It will be fixed in the next update
 

Star-Dust

Expert
Licensed User
Longtime User
Update 0.11
 

Sabotto

Well-Known Member
Licensed User
Great. There remains only the problem that when there is a selected line the checkbox does not respond to the tap. Work for a next update!
 

Star-Dust

Expert
Licensed User
Longtime User
Update 0.12
  • Add method SelectCells (FromRow As Int, FromCol As Int, ToRow As Int, ToCol As Int, Mobile As Boolean)
    If Mobile is True, the selectable area can be enlarged by touching and dragging it to the desired box.
  • Modify method SelectCell (Row As Int, Col As Int, Mobile As Boolean); Add Mobile parameter
  • Fix Bugs
  • Update Example
 
Last edited:

Star-Dust

Expert
Licensed User
Longtime User
This is B4J libraries thread. Is the new version for B4A and B4i only? And its name iSD_FlexGrid? ?
As it is a B4X library, it fits anywhere on the forum.
In any case, one day I will also add B4J .... I think
 

Sabotto

Well-Known Member
Licensed User
Good! update also included the resolution of the checkbox bug. Thank you
 

Star-Dust

Expert
Licensed User
Longtime User
After two and a half years, i Added B4J version still in beta phase. Cell selection is not functional
 
Last edited:

Star-Dust

Expert
Licensed User
Longtime User
Update rel. 0.13
  1. Added cell selection also in B4J
  2. Improved selection visibility. When the selection is activated and it is still editable, the selection frame will be surrounded by a red border.
 

BigBoss123

Member
Licensed User
Longtime User
Hi
Having a problem with this code

B4X:
Private Sub btnClear_Click
    FlexGrid1.ClearSelection
    txtBarcode.Text = " "
    txtCustomer.Text = " "
    txtCategory.Text = "  "
    txtWine.Text = "  "
    txtDest.Text = " "
    txtWare.text = " "
    
End Sub

The Flexgrid is not being cleared. This is running on B4A

Thanks for your help
 

Star-Dust

Expert
Licensed User
Longtime User
This command is used to reset the selection. This does not mean that it deletes the contained data, but that the previously selected data will no longer be selected.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…