想要获取wxPropertyGridPage中属性数值的修改事件就需要,自定义一个wxMyPropertyGridPage从wxPropertyGridPage继承 // ----------------------------------------------------------------------- // wxMyPropertyGridPage // ----------------------------------------------------------------------- class wxMyPropertyGridPage : public wxPropertyGridPage { public: // Return false here to indicate unhandled events should be // propagated to manager's parent, as normal. virtual bool IsHandlingAllEvents() const { return false; } protected: virtual wxPGProperty* DoInsert( wxPGProperty* parent, int index, wxPGProperty* property ) { return wxPropertyGridPage::DoInsert(parent,index,property); } void OnPropertySelect( wxPropertyGridEvent& event ); void OnPropertyChanging( wxPropertyGridEvent& event );//属性网格属性尚未修改,调用的事件,修改的数值在event中 void OnPropertyChange( wxPropertyGridEvent& event );//属性网格属性已经修改,然后调用的事件 void OnPageChange( wxPropertyGridEvent& event ); private: DECLARE_EVENT_TABLE() }; // ----------------------------------------------------------------------- // wxMyPropertyGridPage // ----------------------------------------------------------------------- BEGIN_EVENT_TABLE(wxMyPropertyGridPage, wxPropertyGridPage) EVT_PG_SELECTED( wxID_ANY, wxMyPropertyGridPage::OnPropertySelect ) EVT_PG_CHANGING( wxID_ANY, wxMyPropertyGridPage::OnPropertyChanging ) EVT_PG_CHANGED( wxID_ANY, wxMyPropertyGridPage::OnPropertyChange ) EVT_PG_PAGE_CHANGED( wxID_ANY, wxMyPropertyGridPage::OnPageChange ) END_EVENT_TABLE() void wxMyPropertyGridPage::OnPropertySelect( wxPropertyGridEvent& WXUNUSED(event) ) { wxLogDebug(wxT("wxMyPropertyGridPage::OnPropertySelect()")); } void wxMyPropertyGridPage::OnPropertyChange( wxPropertyGridEvent& event ) { wxPGProperty* p = event.GetProperty(); wxLogDebug(wxT("wxMyPropertyGridPage::OnPropertyChange('%s', to value '%s')"), p->GetName().c_str(), p->GetDisplayedString().c_str()); } void wxMyPropertyGridPage::OnPropertyChanging( wxPropertyGridEvent& event ) { wxPGProperty* p = event.GetProperty(); // // DateTime does not convert cleanly to string wxVariant pendingValue = event.GetValue(); wxString valueString; if ( pendingValue.GetType() == wxT("datetime") && !pendingValue.GetDateTime().IsValid() ) { valueString = wxT("Invalid"); } else { valueString = pendingValue.GetString(); } wxLogDebug(wxT("wxMyPropertyGridPage::OnPropertyChanging('%s', to value '%s')"), p->GetName().c_str(), valueString.c_str()); } void wxMyPropertyGridPage::OnPageChange( wxPropertyGridEvent& WXUNUSED(event) ) { wxLogDebug(wxT("wxMyPropertyGridPage::OnPageChange()")); } 在程序中这样调用。 wxPropertyGridManager* pgman = m_pPropGridManager; wxPropertyGridPage* myPage = new wxMyPropertyGridPage(); pgman->AddPage(wxT("自定义属性"),wxNullBitmap,myPage);