wxGrid without labels

954 views
Skip to first unread message

Thomas Andrews

unread,
Apr 19, 2011, 1:16:10 AM4/19/11
to wx-u...@googlegroups.com
Hi,

Is it possible to have a wxGrid without labels for rows & columns?
Alternatively what would the correct widget be to use instead?

I have tried to use SetRowLabelSize(0) to disable the label, but that
removes the left vertical bar. Similarly SetColLabelSize(0) removes the
top bar.

Many thanks,
Thomas

Kinaou HERVE

unread,
Apr 19, 2011, 7:30:14 AM4/19/11
to wx-u...@googlegroups.com
Hello,

Have you tried using the functions HideRowLabels() and HideColLabels()? (see http://docs.wxwidgets.org/trunk/classwx_grid.html)

Regards,
KH

2011/4/19 Thomas Andrews <tea.a...@gmail.com>

John Roberts

unread,
Apr 19, 2011, 8:23:08 AM4/19/11
to wx-u...@googlegroups.com
Try using SetRowLabelSize(1) and SetColLabelSize(1) if you want to retain a visible line although I am not sure whether you meant you want the full size labels with no label text in which case loop through rows using SetRowLabelValue( row, wxString() ).
Regards, John
 
Hello,

Have you tried using the functions HideRowLabels() and HideColLabels()? (see http://docs.wxwidgets.org/trunk/classwx_grid.html)

Regards,
KH

2011/4/19 Thomas Andrews <tea.a...@gmail.com>
Hi,

Is it possible to have a wxGrid without labels for rows & columns? Alternatively what would the correct widget be to use instead?

I have tried to use SetRowLabelSize(0) to disable the label, but that removes the left vertical bar. Similarly SetColLabelSize(0) removes the top bar.

Many thanks,
Thomas


No virus found in this message.
Checked by AVG - www.avg.com
Version: 10.0.1209 / Virus Database: 1500/3582 - Release Date: 04/18/11

 

alanf

unread,
Apr 19, 2011, 8:44:50 AM4/19/11
to wx-users
Thomas,

I had a similar issue where I did not want to show the label row and
column and I ended up having to do a variety of things. It turns out
that not showing the labels tends to remove the left most border of
the first column and top border of the first row of data cells.

What I ended up having to do is to combine a few things to get the
left and top grid lines to show up (without labels).

Example;

Grid1 = new wxGrid(Panel5,-1,wxPoint( 100,100 ), wxSize (gridwidth,
gridheight), 0, _T("ID_GRID1"));
// next line created a grid with one more row and one more column than
I actually needed, this was to essential allow a spacing factor for
the grid line top and left that was missing
Grid1->CreateGrid(rowcount+1,colcount+1);
Grid1->SetRowMinimalAcceptableHeight(1);
Grid1->SetColMinimalAcceptableWidth(1);
Grid1->SetRowLabelValue(0, _(""));
Grid1->SetRowLabelValue(1, _(""));
wxFont
GridLabelFont_1(8,wxSWISS,wxFONTSTYLE_NORMAL,wxNORMAL,false,wxEmptyString,wxFONTENCODING_DEFAULT);
Grid1->SetLabelFont(GridLabelFont_1);
Grid1->SetDefaultCellFont( Grid1->GetFont() );
Grid1->SetRowSize(0,1);
Grid1->SetColSize(0,1);
int I;
for (i=1; i <= rowcount; i++) {
Grid1->SetRowSize(i,rowheight);
}
for (i=1; i <= colcount; i++) {
Grid1->SetColSize(i,colwidth);
}
Grid1->SetRowLabelSize(0);
Grid1->SetColLabelSize(0);
Grid1->EnableScrolling(false,false);
Grid1->EnableGridLines(true);
Grid1->SetGridLineColour(wxColour(0,0,255));
Grid1->SetMargins(0,0);
Grid1->Refresh();

This may not be all you need but it sufficed for me to get the edge
grid lines without labels.

Additionally, I had the need to not show scroll bars and to ensure the
grid filled my area without the outside padding area (beyond the
actual cells to right and bottom) but I won’t go into that coding
unless you really end up needing it.

Regards,

AM
Reply all
Reply to author
Forward
0 new messages