SetMaxLength for ComboBox

Hi all,
I want to limit the number of characters typed into the text field of a CB_DROPDOWN ComboBox. I thought I had seen a way of getting the TextCtrl so I can apply SetMaxLength(), but can't find any references to it in the archives.

TIA, Phil

Phil Mayes wrote:

Hi all,
I want to limit the number of characters typed into the text field of a CB_DROPDOWN ComboBox. I thought I had seen a way of getting the TextCtrl so I can apply SetMaxLength(), but can't find any references to it in the archives.

Unfortunately there isn't a built-in way to do tha with a combobox. You'll have to catch events (EVT_CHAR and/or maybe EVT_TEXT) and impose the limit yourself.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Rickey, Kyle W wrote:

I was thinking this might work:

for child in combo.GetChildren():
  if isinstance(child, wx.TextCtrl):
    text = child
    break

Until I realized that the ComboBox doesn't have any children.

It may in the native implementation, but wx doesn't have or provide access to it.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!