我尝试使用自定义标签实现自定义wxGrid。根据wxwidgets文档,有必要实现方法: 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("");};
};发布于 2013-02-02 02:55:29
您混淆了wxGrid和wxGridTableBase中的方法。如果要使用自定义表,则需要从后者派生表类,而不是从前者派生。
当然,如果您只需要自定义一些标签,则根本不需要使用定制表,只需调用wxGrid::SetColLabelValue()将其设置为您需要的任何值即可。
https://stackoverflow.com/questions/14650192
复制相似问题