Reputation: 799
I tried to implement a custom wxGrid with custom labels. According to the wxwidgets documentation, it is necessary to implement the Method: SetColLabelValue and GetColLabelValue. Sadly, the methods from the wxGridTableBase class won't get overriden by my code.
#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("");};
};
Upvotes: 0
Views: 870
Reputation: 22753
You've mixed up methods in wxGrid
and wxGridTableBase
. If you want to use a custom table, you need to derive your table class from the latter, not the former.
Of course, if you just need to customize some labels, there is no need to use a custom table at all, just call wxGrid::SetColLabelValue()
to set them to whatever you need.
Upvotes: 1