none
Center Text In a Listbox in Access 2013 RRS feed

  • Question

  • I am trying to center text in a Listbox in Access 2013.

    There does not appear to be any text align option in the properties for the listbox.

    I have not been able to find an example on line that will open in Access 2013, only a 'justification' example that does not open.

    I have tried changing to 'text mode' in the Options, Client Settings, 'General Alignment' option, converting the listbox to a combo box, changing the text align property to center, converting the combo box back to a listbox. However, the text remains left aligned.

    Any ideas?

    Thank you


    Nath

    Monday, January 9, 2017 1:39 PM

Answers

  • One way is to simulate the list box by means of a subform designed in such a way to appear like a list box..  You'll find an example of how to do this as DummyList.zip in my public databases folder at:

    https://onedrive.live.com/?cid=44CC60D7FEA42912&id=44CC60D7FEA42912!169

    Note that if you are using an earlier version of Access you might find that the colour of some form objects such as buttons shows incorrectly and you will need to  amend the form design accordingly.  

    If you have difficulty opening the link copy its text (NB, not the link location) and paste it into your browser's address bar.

    In this little demo file conditional formatting is used to show the selected item by means of an expression which returns True if the value of the row's primary key equals the value of a hidden unbound control with the value of the current record.  The controls in the subform can of course be formatted in many ways, so the possibilities are only limited by your imagination.  To simulate the use of a list box's AfterUpdate event procedure to perform some action, the necessary code would be placed in the subform's Current event procedure.

    Ken Sheridan, Stafford, England

    • Marked as answer by NaPazz Wednesday, January 11, 2017 6:29 AM
    Tuesday, January 10, 2017 11:24 PM

All replies

  • To my knowledge it cannot be done.

    That said, Stephen Lebans does have an old demo db, see: http://lebans.com/justicombo.htm it might be worth checking out.


    Daniel Pineault, 2010-2016 Microsoft MVP
    Professional Support: http://www.cardaconsultants.com  
    MS Access Tips and Code Samples: http://www.devhut.net


    Monday, January 9, 2017 2:26 PM
  • Hi NaPazz,

    I try to search the properties of listbox. but there is no any property available that can set the list box options to center.

    you can see the properties below.

    if you think that this feature should be add in future update then please submit your feedback below.

    Access User Voice

    Regards

    Deepak


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, January 10, 2017 2:11 AM
    Moderator
  • One way is to simulate the list box by means of a subform designed in such a way to appear like a list box..  You'll find an example of how to do this as DummyList.zip in my public databases folder at:

    https://onedrive.live.com/?cid=44CC60D7FEA42912&id=44CC60D7FEA42912!169

    Note that if you are using an earlier version of Access you might find that the colour of some form objects such as buttons shows incorrectly and you will need to  amend the form design accordingly.  

    If you have difficulty opening the link copy its text (NB, not the link location) and paste it into your browser's address bar.

    In this little demo file conditional formatting is used to show the selected item by means of an expression which returns True if the value of the row's primary key equals the value of a hidden unbound control with the value of the current record.  The controls in the subform can of course be formatted in many ways, so the possibilities are only limited by your imagination.  To simulate the use of a list box's AfterUpdate event procedure to perform some action, the necessary code would be placed in the subform's Current event procedure.

    Ken Sheridan, Stafford, England

    • Marked as answer by NaPazz Wednesday, January 11, 2017 6:29 AM
    Tuesday, January 10, 2017 11:24 PM
  • Thanks Ken. That is a beautiful solution.

    Nath

    Wednesday, January 11, 2017 6:29 AM
  • Hi Ken

    Thanks for a great work around.

    Michael

    Tuesday, December 17, 2019 12:32 PM