Editing a cell in a listbox - text position

Hi, apologies if this has already been covered elsewhere, I did search but couldn’t find anything.

Is there a way to control the appearance of the TextField that appears when you click on an editable cell in a listbox? e.g. centre the text vertically so its inline with the rest of the row?

See attached pic, looks a bit rubbish on a Mac (not tried on other platforms).


File a bug report using Feedback.

Don’t hold your breath 'till the bug wll be removed…

Hi Emile, thanks for replying, but I’ve worked around it.

In the listbox’s CellClick event:

me.EditCell row, Column

if row = 0 Then
  me.ActiveTextControl.Top = me.ActiveTextControl.Top+1
  me.ActiveTextControl.Height = me.RowHeight-6
  me.ActiveTextControl.Top = me.ActiveTextControl.Top+4
  me.ActiveTextControl.Height = me.RowHeight-6

me.ActiveTextControl.AllowFocusRing = false

… gives a far better user experience:


1 Like

This code takes care of variable Listbox.DefaultRowHeight > -1:

Me.EditCellAt(row, column)

Static dTextHeight As Double

If dTextHeight = 0 Then
  Var p As New Picture(1, 1)
  Var g As Graphics = p.Graphics
  g.FontName = Me.FontName
  g.FontSize = Me.FontSize
  dTextHeight = g.TextHeight
End If

Me.ActiveTextControl.Height = dTextHeight
Me.ActiveTextControl.Top = Me.ActiveTextControl.Top + (Me.RowHeight / 2) - (Me.ActiveTextControl.Height / 2)


Thank you for the code.

Forum for Xojo Programming Language and IDE. Copyright © 2021 Xojo, Inc.