If WebListBox Column Alignment and ColumnStyle no longer an option?
Thanks
If WebListBox Column Alignment and ColumnStyle no longer an option?
Thanks
Take a look at
[http://documentation.xojo.com/api/user_interface/web/weblistbox.htmlStyleRenderer](http://documentation.xojo.com/api/user_interface/web/weblistbox.htmlStyleRenderer)
there is no textalignment in the webstyle.
do you have to use the CSS of the webstyle to center a text in a cell ?
Thanks very much Jean-Yves and Hector
So has someone a solution to get right aligned text into a WebListbox in Xojo 2021?
As @Hector_Marroquin said, you can do it using WebListBoxStyleRenderer.
Var style As New WebStyle
style.Value("text-align") = "right"
Me.CellValueAt(0,0) = New WebListBoxStyleRenderer(style, "Hello World!")
Hoping someone can assist me with this. I am trying to right align columns 4 to 9 but i’m not sure exactly how to do this.
Assistance would be much appreciated.
Var style as New WebStyle
style.Value(“text-align”) = “right”
Me.CellValueAt(0,0) = New WebListBoxStyleRenderer(style, “Hello World!”)
Var Rows as RowSet
Replenishment_Lst.HeaderAt(0) = “Code”
Replenishment_Lst.HeaderAt(1) = “Name”
Replenishment_Lst.HeaderAt(2) = “Location”
Replenishment_Lst.HeaderAt(3) = “Supplier”
Replenishment_Lst.HeaderAt(4) = “Latest Cost”
Replenishment_Lst.HeaderAt(5) = “On Hand”
Replenishment_Lst.HeaderAt(6) = “On PO”
Replenishment_Lst.HeaderAt(7) = “Reorder Point”
Replenishment_Lst.HeaderAt(8) = “Suggested Order Qty”
Replenishment_Lst.HeaderAt(9) = “Suggested Order Cost”
Rows = Session.DB.SelectSQL(“Select * from Item order by ItemCode”)
If Rows <> Nil Then
Replenishment_Lst.RemoveAllRows
For Each Row As DatabaseRow In Rows
If Row.Column("ItemModelStockQtyManual").StringValue.ToDouble <> 0 and Row.Column("ItemOnHandQty").StringValue.ToDouble + Row.Column("ItemOnPurOrderQty").StringValue.ToDouble <= Row.Column("ItemModelStockQtyManual").StringValue.ToDouble Then
Replenishment_Lst.AddRow(Row.Column("ItemCode").StringValue, _
Row.Column("ItemName").StringValue, _
Row.Column("ItemLocation").StringValue.Left(10), _
Row.Column("ItemSupplierName").StringValue.Left(15), _
Row.Column("ItemCost").StringValue, _
Row.Column("ItemOnHandQty").StringValue, _
Row.Column("ItemOnPurOrderQty").StringValue, _
Row.Column("ItemModelStockQtyManual").StringValue, _
Row.Column("ItemOptimumOrderQtyManual").StringValue, _
Row.Column("ItemOptimumOrderValueManual").StringValue)
Replenishment_Lst.CellTagAt(Replenishment_Lst.LastAddedRowIndex, 0) = Row.Column("ID").IntegerValue
TotalOrder = TotalOrder + Row.Column("ItemOptimumOrderValueManual").StringValue.ToDouble
ElseIf Row.Column("ItemModelStockQtyMovingAvg").StringValue.ToDouble <> 0 and Row.Column("ItemOnHandQty").StringValue.ToDouble + Row.Column("ItemOnPurOrderQty").StringValue.ToDouble <= Row.Column("ItemModelStockQtyMovingAvg").StringValue.ToDouble Then
Replenishment_Lst.AddRow(Row.Column("ItemCode").StringValue, _
Row.Column("ItemName").StringValue, _
Row.Column("ItemLocation").StringValue.Left(10), _
Row.Column("ItemSupplierName").StringValue.Left(15), _
Row.Column("ItemCost").StringValue, _
Row.Column("ItemOnHandQty").StringValue, _
Row.Column("ItemOnPurOrderQty").StringValue, _
Row.Column("ItemModelStockQtyMovingAvg").StringValue, _
Row.Column("ItemOptimumOrderQtyMovingAvg").StringValue, _
Row.Column("ItemOptimumOrderValueMovingAvg").StringValue)
Replenishment_Lst.CellTagAt(Replenishment_Lst.LastAddedRowIndex, 0) = Row.Column("ID").IntegerValue
TotalOrder = TotalOrder + Row.Column("ItemOptimumOrderValueMovingAvg").StringValue.ToDouble
End If
Next
Rows.Close
End If
Hi @Craig_Wyeth1,
The way to use cell renderers is to use them after adding the row:
Replenishment_Lst.AddRow("...")
Var rowIndex As Integer = Replenishment_Lst.LastAddedRowIndex
For i As Integer = 4 To 9
Replenishment_Lst.CellTextAt(rowIndex, i) = New WebListBoxStyleRenderer(style, Me.CellTextAt(rowIndex, i))
Next
Please note CellValueAt
is now called CellTextAt
.
Works perfectly.
Thanks Ricardo
Dear, in 2022r2 I still can’t align a column to the right, a complete example of how to do it please, thanks!
Try creating a WebListBox, with 3 columns. In its Opening
event, paste this code:
Var centeredStyle As New WebStyle
centeredStyle.Value("text-align") = "center"
Var rightAlignedStyle As New WebStyle
rightAlignedStyle.Value("text-align") = "right"
Var leftAlignedValue, centeredValue, rightAlignedValue As String
For i As Integer = 1 To 10
leftAlignedValue = "Left " + i.ToString
centeredValue = "Center " + i.ToString
rightAlignedValue = "Right " + i.ToString
Me.AddRow(leftAlignedValue, centeredValue, rightAlignedValue)
Var row As Integer = Me.LastAddedRowIndex
Me.CellTextAt(row, 1) = New WebListBoxStyleRenderer(centeredStyle, centeredValue)
Me.CellTextAt(row, 2) = New WebListBoxStyleRenderer(rightAlignedStyle, rightAlignedValue)
Next
You should see something like this:
I hope that helps!
Hola @Ricardo_Cruz,
I have the weblistbox inside a webdialog and I set up all the sending of data from the webcontainer that calls it, I show you the method:
Tengo el weblistbox dentro de un webdialog y armo todo el envĂo de datos desde el webcontainer que lo llama, te muestro el mĂ©todo:
No me esta funcionando
… otras variables …
Var leftAlignedValue, centeredValue, rightAlignedValue As String
Var row As Integer
Var centeredStyle As New WebStyle
centeredStyle.Value(“text-align”) = “center”
Var rightAlignedStyle As New WebStyle
rightAlignedStyle.Value(“text-align”) = “right”
If Session.DBOpen Then
strSQL = …
larsRecordset = Session.mDB.SelectSQL(strSQL)
if Not larsRecordset.AfterLastRow then
wdDetalleCaja1.lstDetalle.RemoveAllRows
wdDetalleCaja1.lstDetalle.ColumnCount = 2
wdDetalleCaja1.lstDetalle.ColumnWidths = “60%,40%”
while Not larsRecordset.AfterLastRow
dblTotal = larsRecordset.Column(“campo2”).DoubleValue
strCaja = larsRecordset.Column(“campo3”).StringValue
strImporte = "$ " + Format(dblTotal, Formato_Entero) '+ “­â€ť
wdDetalleCaja1.lstDetalle.AddRow (strCaja, strImporte)
**row = wdDetalleCaja1.lstDetalle.LastAddedRowIndex**
** wdDetalleCaja1.lstDetalle.CellTextAt(row, 0) = New WebListBoxStyleRenderer(centeredStyle, centeredValue)**
** wdDetalleCaja1.lstDetalle.CellTextAt(row, 1) = New WebListBoxStyleRenderer(rightAlignedStyle, rightAlignedValue)**
' siguiente
larsRecordset.MoveToNextRow
wend
end if
end if
Session.DBClose
wdDetalleCaja1.Show
What part isn’t working?, are you getting any error?
Please wrap the code using the “Preformatted Text” option, so we can see it properly in the forum.
¿Qué es lo que no funciona?, ¿te da algún error?
Prueba a meter el código dentro de la opción “Preformatted Text”, para que lo veamos bien en el foro.