在对话框(wxDialog)中拟合一个大网格(wxGrid) [英] Fitting a big grid (wxGrid) in a dialog (wxDialog)

查看:126
本文介绍了在对话框(wxDialog)中拟合一个大网格(wxGrid)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的布局:

  • 我有一个尺寸调整器,其中包含一个网格(比例为1)和一个确定/取消"按钮栏

  • I have a sizer that contains a grid (with a proportion of 1) and a ok/cancel button bar

所有内容都在一个wxDialog中

The all thing is in a wxDialog

这里是:

|||||||||||||||
|             |
|    GRID     |
|             |
|             |
|             |
|||||||||||||||
| OK  CANCEL  |
|||||||||||||||

问题是网格包含太多行,并且屏幕溢出,所以最后我看不到对话框的顶部.在对话框上调用Fit()时,是否有办法限制其高度?

The issue is that the grid contains too many row, and over flow the screen, so in the end I don't see the top part of the dialog. Is there a way, when calling Fit() on the dialog, to limit its height ?

我尝试了以下内容:SetSizeHints(-1,-1,-1,500);SetMaxSize(500,500),但是没有用.

I have tried stuff like this: SetSizeHints(-1,-1,-1,500); and SetMaxSize(500,500) but it did not worked.

我也尝试这样做:this->SetSize(this->GetSize().GetX(), 500);,但是由于垂直滚动条出现在网格上,所以它不够宽,因此会出现水平滚动条.

Also I have tried to do that: this->SetSize(this->GetSize().GetX(), 500);, but since the vertical scroll bar appears on the grid, it is not wide enough and a horizontal scroll bar shows up.

编辑

在构造函数中,我调用wxGrid(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize)

In the constructor I call wxGrid(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize)

推荐答案

最简单的方法是使用固定大小的网格.如果行数超过了适合的行数,则会出现滚动条.您可以在构造函数中设置所需的大小.

The easiest way to handle this is to use a grid of fixed size. If there are more rows than will fit, then a scroll bar will appear. You set the size you want in the constructor.

new wxGrid( this, IDC_grid, wxPoint(-1,-1),wxSize(igridxsize,igridysize));

如果要调整网格的大小,例如当用户调整应用程序窗口的大小时,事情会更加复杂.您需要处理窗口大小事件并适当地更改网格大小.

If you want the size of the grid to adjust, e.g. when the user resizes the application window, things are a bit more complex. You need handle the window size event and change the grid size as appropriate.

遵循以下原则:

myDialog::OnSize(wxSizeEvent& event);
{
wxSize dialogSize = event.GetSize();
myGrid->OnSize( wxSizeEvent(
     dialogSize.GetWidth() * 0.9, dialogSize.GetHeight() * 0.7 ));
}

这篇关于在对话框(wxDialog)中拟合一个大网格(wxGrid)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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