Add new columns to Grid

grant1842

Active Member
Licensed User
Longtime User
I am looking at the Grid Sample HERE .

I am trying to add some extra columns to the grid example.
'--- Define the columns to be shown by the grid
'--- Columns First Row

and I added them in the array
'--- Add the columns to a list

My new columns will not show up in the grid.

All so I do not need to show any radio buttons.

I need a grid with 6 colums.

COLUMS = ( Name1-Name2-bd1-r1- c1-d1 )

Here are the changes I have made to the code.

B4X:
 '--- Define the columns to be shown by the grid
   '--- Columns First Row
   Dim colID As TColumn: Grid.InitializeColumn(colID, "Name1", "Name1", "Name1", "", 65dip, Grid.GLABEL, Gravity.RIGHT + Gravity.CENTER_VERTICAL): colID.AutoHeight = True: colID.FooterText = "n1s": colID.SummaryType = Grid.SNUMBER_SUM
   Dim colName As TColumn: Grid.InitializeColumn(colName, "NAME2", "NAME2", "NAME2", "NAME2", 100%x - 80dip - ImageSize - colID.Width - Grid.SPACING * 2, Grid.GRADIOBUTTON, 0): colName.AutoHeight = True: colName.FooterText = "n2s ": colName.SummaryType = Grid.SCOUNT
   Dim colNumber As TColumn: Grid.InitializeColumn(colNumber, "Bd", "Bd", "BD", "", 80dip, Grid.GLABEL, Gravity.RIGHT + Gravity.CENTER_VERTICAL): colNumber.AutoHeight = True: colNumber.FooterText = "sc: ": colNumber.SummaryType = Grid.SNUMBER_AVG: colNumber.NumberIntegersMin = 1: colNumber.NumberFractions = 2: colNumber.NumberGrouping = False
   Dim colDelete As TColumn: Grid.InitializeColumn(colDelete, "", "ID", "", "btnDelete", ImageSize + Grid.SPACING * 2, Grid.GBUTTON, 0): colDelete.MinHeight = ImageSize: colDelete.Icon = LoadBitmapSample(File.DirAssets, "delete2.png", ImageSize, ImageSize)
   Dim colr1 As TColumn: Grid.InitializeColumn(colr1, "r1", "r1", "r1", "", 80dip, Grid.GLABEL, Gravity.RIGHT + Gravity.CENTER_VERTICAL): colr1.AutoHeight = True: colr1.SummaryType = Grid.SNUMBER_AVG: colr1.NumberIntegersMin = 1: colr1.NumberFractions = 2: colr1.NumberGrouping = False
   Dim colc1 As TColumn: Grid.InitializeColumn(colc1, "C1", "C1", "C1", "", 80dip, Grid.GLABEL, Gravity.RIGHT + Gravity.CENTER_VERTICAL): colc1.AutoHeight = True: colc1.SummaryType = Grid.SNUMBER_AVG: colc1.NumberIntegersMin = 1: colc1.NumberFractions = 2: colc1.NumberGrouping = False
   Dim cold1 As TColumn: Grid.InitializeColumn(cold1, "d1", "d1", "d1", "d1", 100%x - 80dip - ImageSize - cold1.Width - Grid.SPACING * 2, Grid.GRADIOBUTTON, 0): cold1.AutoHeight = True: cold1.FooterText = "Count: ": cold1.SummaryType = Grid.SCOUNT
   
   '--- Columns Second Row
   Dim colAddress As  TColumn: Grid.InitializeColumn(colAddress, "ADDRESS", "", "Address", "", 65%x, Grid.GLABEL, Gravity.LEFT + Gravity.TOP): colAddress.AutoHeight = True: colAddress.CustomFontSize = Grid.FONTSIZE - 2: colAddress.IsSecondRow = True: colAddress.CustomTextColor = Colors.ARGB(255, 230, 225, 215)
   Dim colFunction As TColumn: Grid.InitializeColumn(colFunction, "FUNCTION", "", "Function", "", 35%x, Grid.GLABEL, 0): colFunction.AutoHeight = True: colFunction.IsSecondRow = True
   '--- Add the columns to a list
   Dim lstColumns As List: lstColumns.Initialize(): lstColumns.AddAll(Array As TColumn(colID, colName, colNumber, colDelete, colAddress, colFunction, colr1, colc1, cold1))

I am attaching code .

If someone could help me figure out why they will not show up that would be great.
Thanks for helping me.
 

Attachments

  • grid.zip
    35.7 KB · Views: 245

mangojack

Well-Known Member
Licensed User
Longtime User
B4X:
Dim colName As TColumn: Grid.InitializeColumn(colName, "NAME2", "NAME2", "NAME2", "NAME2", 100%x - 80dip - ImageSize - colID.Width - Grid.SPACING * 2, Grid.GRADIOBUTTON, 0): colName.AutoHeight = True: colName.FooterText = "n2s ": colName.SummaryType = Grid.SCOUNT

the second column width you have set to .. 100%x - 80dip - ImageSize - minus this and minus that .. That width is sending the other columns out of view. There must be a more concise way of setting the second columns width ?

To view your other columns try this (you will still have to calculate the correct width ..)

B4X:
Dim colName As TColumn: Grid.InitializeColumn(colName, "NAME2", "NAME2", "NAME2", "NAME2", 200dip - Grid.SPACING * 2, Grid.GRADIOBUTTON, 0): colName.AutoHeight = True: colName.FooterText = "n2s ": colName.SummaryType = Grid.SCOUNT

If I get time I will look at the code closer re .. not wanting the radio buttons.

Cheers mj
 
Upvote 0

mangojack

Well-Known Member
Licensed User
Longtime User
Just following up ..
B4X:
Dim cold1 As TColumn: Grid.InitializeColumn(cold1, "d1", "d1", "d1", "d1", 100%x - 80dip - ImageSize - cold1.Width - Grid.SPACING * 2, Grid.GRADIOBUTTON, 0): cold1.AutoHeight = True: cold1.FooterText = "Count: ": cold1.SummaryType = Grid.SCOUNT

Maybe look at the this columns width as well ...

Cheers mj
 
Last edited:
Upvote 0
Top