Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS General Discussion » CExtGridCellComboBox, dynamic content Collapse All
Subject Author Date
a a Feb 23, 2006 - 12:49 AM

Hi.


I have derived a CExtGridCellComboBox cell, to make a cell with a "dynamic" combo box cell.
The content of a listbox is created just when the user clicks on the combo box button.


I tried something like this, by overriding OnPopupListBoxInitContent:


    bool ComboBoxCell::OnPopupListBoxInitContent(CExtPopupInplaceListBox &wndListBox,
      CExtGridCell::TrackCellStateInfo_t &_tcsi)
    {
      Reload(); // reloads the content, by calling AddString, ResetContent, etc...


      if (!CExtGridCellComboBox::
        OnPopupListBoxInitContent(wndListBox, _tcsi))
        return false;
     
      return true;
    }


It works, but there is an inconvenient.
It seems the height of the list box (that is to be shown) is determined before the reload,
which results in a popup listbox with a height not fitting the content.


For instance, if there is 1 item before OnPopupListBoxInitContent is called, and if Reload() adds an item, the popup listbox’s height is calculated
so that just 1 item is shown (though the scroll bar recognizes the second item).


Is there a trick to update the size of this list box?


Thanks.

Technical Support Feb 23, 2006 - 10:32 AM

You can override OnPopupListBoxMeasureTrackSize() to perform your own calculations of the size of pop-up list box. Please note, if you override the OnPopupListBoxInitContent() method and initialize ListBox yourself, you don’t need to invoke the base class method.

a a Feb 23, 2006 - 6:33 PM

It seems OnPopupListBoxMeasureTrackSize is called before OnPopupListBoxInitContent.
I guess OnPopupListBoxInitContent wasn’t made for this kind of initialization.


What’s the first event called when the user clicks on the combobox button?
(where I should implement the initialization of items)

Technical Support Feb 25, 2006 - 2:19 AM

Yes, the OnPopupListBoxMeasureTrackSize() method is called before OnPopupListBoxInitContent() is called.


a a Feb 26, 2006 - 5:51 PM

What’s the first event called when the user clicks on the combobox button?
(where I should implement the initialization of items)

Technical Support Feb 27, 2006 - 8:43 AM

It is not important which event is called first because they are independent. OnPopupListBoxInitContent() is designed for initialization only and OnPopupListBoxMeasureTrackSize() for measuring the size of the popup list box only. OnPopupListBoxMeasureTrackSize() is performed automatically if you use the combo cell in the standard way. When you initialize items dynamically, instead of standard implementation, the OnPopupListBoxMeasureTrackSize() knows nothing about the content of the combo box (the m_arrItems array is empty). So you need to prepare your array of the items before these events occur. It can be done in a CExtGridCell::OnButtonPopupMenuTrack() overridden method.

a a Feb 27, 2006 - 6:22 PM

CExtGridCell::OnButtonPopupMenuTrack()

Thanks. This is what I wanted.