【问题标题】:wxWidgets Custom wxGridwxWidgets 自定义 wxGrid
【发布时间】:2013-01-16 23:53:07
【问题描述】:

我尝试使用自定义标签实现自定义 wxGrid。根据 wxwidgets 文档,需要实现 Method:SetColLabelValue 和 GetColLabelValue。遗憾的是,来自 wxGridTableBase 类的方法不会被我的代码覆盖。

#pragma once
#include <wx/grid.h>
#include <wx/string.h>
#include <wx/event.h>
#include <wx/string.h>
#include <vector>
class Grid :
    public wxGrid
{
    unsigned int m_rows_occupied;
    std::vector<wxString> m_colLabels;
    wxString* m_colLabelsArr;
public:
    Grid(wxWindow* _parent,wxWindowID _ID,wxPoint _pos,wxSize _size,long _style);
    ~Grid(void);
    void InsertValues(char* _col1,char* _col2);
    void SetRow(unsigned int _row,char* _col1,char* _col2);
    void SetCell(unsigned int _row,unsigned int _cell,char* _col1);
    unsigned int* Size(void){return &m_rows_occupied;};
    virtual void SetColLabelValue( int WXUNUSED(col), const wxString& )override;
    virtual wxString GetColLabelValue(int col) override{return wxString("");};
};

【问题讨论】:

  • 您正在使用“覆盖”一个 C++11 关键字,但已将此问题标记为不支持 C++11 的 VS2005
  • 2005版本支持(clr模式和正常),但是我在方法内部设置了断点,它们没有被调用

标签: visual-c++ user-interface visual-studio-2005 wxwidgets


【解决方案1】:

您混淆了wxGridwxGridTableBase 中的方法。如果您想使用自定义表格,则需要从后者而不是前者派生您的表格类。

当然,如果你只是需要自定义一些标签,完全不需要使用自定义表格,只需调用wxGrid::SetColLabelValue()将它们设置为你需要的任何东西。

【讨论】:

  • 我确实把id弄混了,但我终于弄明白了。没有办法实现我自己的 GridTableBase。感谢您的意见。
猜你喜欢
  • 1970-01-01
  • 2019-12-17
  • 1970-01-01
  • 1970-01-01
  • 2011-05-01
  • 1970-01-01
  • 2011-04-23
  • 1970-01-01
  • 2019-04-11
相关资源
最近更新 更多