wxGrid 在右侧显示大的空边框 [英] wxGrid shows large empty border on right

查看:32
本文介绍了wxGrid 在右侧显示大的空边框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

默认情况下,wxGrid 在最后一列之后的右侧显示一个小的(10 像素?)空白边框.调用 SetMargins() 对它没有影响.

By default, wxGrid shows a small ( 10 pixels? ) blank border on the right hand side, after the last column. Calling SetMargins() has no effect on it.

这很烦人,但我可以忍受.

It is irritating, but I can live with it.

但是,如果我将行标签宽度设置为零,则空白边框会变得更大.如果我只有一列,效果会很糟糕.看起来 wxGrid 为不存在的标签留出了空间.

However, if I set the the row label width to zero then the blank border grows much larger. If I have just one column, the effect is horrible. It looks like wxGrid is leaving room for the non-existent label.

myPatGrid = new wxGrid(panel,IDC_PatGrid,wxPoint(10,10),wxSize(150,300) );
myPatGrid->SetRowLabelSize(0); 
myPatGrid->CreateGrid(200,1);
myPatGrid->SetColLabelValue(0,L"Patient IDs");

有没有办法去掉这个边框?

Is there a way to remove this border?

请注意,如果我在 wxGrid 构造函数中将 wxgrid 窗口的大小设置为更窄,希望隐藏边框,我现在会得到一个水平滚动条,这也太可怕了.

Note that if I set the size of the wxgrid window to narrower in the wxGrid constructor, hoping to hide the border, I now get a horizontal scroll bar which is horrible too.

myPatGrid = new wxGrid(panel,IDC_PatGrid,wxPoint(10,10),wxSize(100,300) );
myPatGrid->SetRowLabelSize(0); 
myPatGrid->CreateGrid(200,1);
myPatGrid->SetColLabelValue(0,L"Patient IDs");

给我

我刚刚升级到 wxWidgets v2.8.12 - 问题仍然存在.

I just upgraded to wxWidgets v2.8.12 - problem still exists.

推荐答案

我没有找到自动调整大小"功能来适应网格空间中的列.作为一种解决方法,如果您只有一列,则将其宽度设置为

I didn't find an "autosize" function to fit columns in the grid space. As a workaround, if you have only one column set its width to

myPatGrid->SetColMinimalWidth(0, grid_width - wxSYS_VSCROLL_X - 10)

否则,将其他列的宽度相加并调整最后一列以适应剩余空间(减去滚动条宽度,减去 10).

otherwise, sum other column's width and adapt the last one to fit the remaining space (minus scrollbar width, minus 10).

编辑:我有一个工作示例,它产生了这个:

EDIT: I have a working example, which produces this:

int gridSize = 150;
int minSize = gridSize - wxSYS_VSCROLL_X - 2; // scrollbar appear if higher
grid->SetRowLabelSize(0);
grid->SetColMinimalWidth(0, minSize);
grid->SetColSize(0, minSize); // needed, otherwise column will not resize
grid->ForceRefresh();
grid->SetColLabelValue(0, "COORD");

EDIT2:我成功删除了剩余的边距:

EDIT2: I succeded to remove the remaining margin with this:

int gridSize = 150;
int minSize = gridSize - 16; // trial & error
grid->SetMargins(0 - wxSYS_VSCROLL_X, 0);

这篇关于wxGrid 在右侧显示大的空边框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆