CellAlignmentOffset vs ColumnAlignmentOffset

I understand where CellAlignment takes the value of ColumnAlignmet if CellAlignment is set to “default”, and the same with CellType and ColumnType

But at what point does CellAlignmentOffset take on the value of ColumnAlignmentOffset?
Since this is a numeric value, there is no “default” indicator… CellAlignmentOffset ALWAYS has a value

Maybe I don’t understand the question, but after reading https://documentation.xojo.com/api/deprecated/listbox.html.CellAlignmentOffset

I think that CellAlignmentOffset is not taking the value of ColumnAlignmentOffset, if CellAlignmentOffset = 0 then the offset for the cell will be the value of ColumnAlignmentOffset, if CellAlignmentOffset <>0 then that value will override the value in ColumnAlignmentOffset

That doesn’t make sense… otherwise you could not have a ColumnAlignoffset that was NOT zero, and a individual cell the IS zero

and the documentation I have does NOT have what you quoted… .
It has similar statements for the other two properties I mentioned, but not the Offset one

but I did find older documentatin that indicates if CellAlignmentOffset = 0 then use ColumnAlignmentOffset

but again how would you set just one cell to be zero

[quote=442498:@Dave S]That doesn’t make sense… otherwise you could not have a ColumnAlignoffset that was NOT zero, and a individual cell the IS zero

and the documentation I have does NOT have what you quoted… .
It has similar statements for the other two properties I mentioned, but not the Offset one[/quote]

Mmmm, still don’t understand. Sorry.

The URL I put, there is only some text between the square with how to use it and the example, this is it:

I don’t understand how you can land on a different document.

[quote=442499:@Dave S]but I did find older documentatin that indicates if CellAlignmentOffset = 0 then use ColumnAlignmentOffset

but again how would you set just one cell to be zero[/quote]

You need to check if the ColumnAlignmentOffset <> 0 then put the negative of that number on CellAlignmentOffset

listbox1.ColumnAlignmentOffset(5)=10 // set column 5 default offset to be 10
listbox1.CellAlignmentOffset(5,3)=0 // cannot do that, as a zero value would force the default to be used.... you cannot get Zero this way

that would be “fine” if the values were added together… but they are not…
It seems to look at CELL and if that is zero, then it takes the value from COLUMN

The online and internal documents don’t line up exactly it seems

[quote=442502:@Dave S] listbox1.ColumnAlignmentOffset(5)=10 // set column 5 default offset to be 10 listbox1.CellAlignmentOffset(5,3)=0 // cannot do that, as a zero value would force the default to be used.... you cannot get Zero this way [/quote]
Exactly, you need:
listbox1.CellAlignmentOffset(5,3) = listbox1.ColumnAlignmentOffset(5) * (-1)
I still don’t know if that is what you want. I hope this helps.
Edit: It looks like my test is not correct. Sorry. It looks like having a default cell with -10 is the same as having it with 0. More testing…

[quote=442503:@Dave S]that would be “fine” if the values were added together… but they are not…
It seems to look at CELL and if that is zero, then it takes the value from COLUMN[/quote]

Of course you could just set CellAlignment Offset = 1 fro the cells that should not be offset in that column … a one pixel difference offset from other columns likely would not be noticed.

Alternatively you could draw the string yourself in CellText paint and have full control of placement.

That said Xojo inc should likely have used a “magic Number” constant (maybe = maxInt, named UseColumnOffset as the default value for CellAligmentOffset ).

  • Karen

NO… that would offset Cell(5,3) by -10 not by zero

THAT would be the more correct thing to do

True… but that is NOT the correct thing do to … its a bandaid/workaround. :)… but I guess is what I will do for now

Yes Dave, I found the problem, sorry for the wrong information.

Personally, I think that this is a bug. If I specify valid values for the offsets I would expect them to be used.

Feedback report 56161

Not a “bug” so much as a situation that cannot be dealt with…

Xojo does exactly what the documention says…

[quote=442558:@Dave S]Not a “bug” so much as a situation that cannot be dealt with…

Xojo does exactly what the documention says…[/quote]

I call such things design bugs … but in this case I am not sure it can be ‘fixed’ without potentially breaking existing code.

  • karen

a “Magic Number” is the only real solution…

Dave, what if you try setting the CellAlignmentOffset to the negative of the ColumnAlignmentOffset.

Me.CellAlignmentOffset(row, column) = -Me.ColumnAlignmentOffset(column)

then the column is offset by a negative value… see above…

If CellAlignmentOffset is ZERO then it takes on the value of ColumnAlignmentOffset

so

lb.ColumnAlignmentOffset(3)= 10  // by default move all columns 10 pixels right
lb.CellALignmentOffset(3,3)= -lb.ColumnAlignmentOffset(3)  // this cell is now offset by -10 pixels.. .not by zero

basically the internal code acts like this

Get
  If cellAlignmentOffset=0 Then Return columnAlignmentOffset
  Return cellAlignmentOffset
End Get

Set
  cellAlignmentOffset = value
End Set

as Karen had suggested it SHOULD be

Get
  If cellAlignmentOffset=MAGIC_NUMBER Then Return columnAlignmentOffset
  Return cellAlignmentOffset
End Get

Set
  cellAlignmentOffset = value
End Set

Dave,
I understand your frustration.
When a type has no default value we may find some problems, as in this case.
I remember some time ago I wrote a function that received a parameter type Color.
I pretended to do something if this parameter was not assigned (I pretended a default value), but if you don’t assign a variable type colour what you get is the black colour. Black colour is too normal to be used as default.
So I had to invent a strange colour as default (fortunately there are so many colours, that it was not difficult). So if you didn’t provide the colour, default was used. I agree that the “magic number” is the only real solution.

Sub mySub(a As integer, b As double, c As color = &c998877) If c = &c998877 Then 'Default colour Else '... End If End Sub

I use a similar routine for color… but I use &c010101 as my “magic color”