wxWidgets之wxGrid控件

1. 介绍

    wxGrid控件时wxWidgets界面库中内置的网格控件。

通经常使用来显示表格数据。该控件拥有强大的功能。开发人员可依据自己的需求对其进行定制。

2. 经常使用API     
     构造函数:wxGrid ()wxGrid (wxWindow *parent, wxWindowID id, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxWANTS_CHARS, const wxString &name=wxGridNameStr)       创建表格的API:// 创建一个空的表格bool Create (wxWindow *parent, wxWindowID id, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxWANTS_CHARS, const wxString &name=wxGridNameStr)// 创建一个指定行,制定列的表格bool CreateGrid (int numRows, int numCols, wxGridSelectionModes selmode=wxGridSelectCells)关于大小的API:                 // 获取列标签的高度int GetColLabelSize () const// 获取指定列的宽度int GetColSize (int col) const// 获取默认的列标签宽度int GetDefaultColLabelSize () const// 获取默认的列宽int GetDefaultColSize () const// 获取默认的行标签宽度int GetDefaultRowLabelSize () const// 获取默认的行高度int GetDefaultRowSize () const// 获取行标签的宽度int GetRowLabelSize () const// 获取指定行的高度int GetRowSize (int row) const// 设置指定列的宽度void SetColSize (int col, int width)// 设置列标签的高度void SetColLabelSize (int height)// 设置默认的列宽度void SetDefaultColSize (int width, bool resizeExistingCols=false)// 设置默认的行高度void SetDefaultRowSize (int height, bool resizeExistingRows=false)// 设置行标签的宽度void SetRowLabelSize (int width)// 设置指定行的高度void SetRowSize (int row, int height)// 获取列的大小信息wxGridSizesInfo GetColSizes () const// 获取行的大小信息wxGridSizesInfo GetRowSizes () const// 设置列的大小信息void SetColSizes (const wxGridSizesInfo &sizeInfo)// 设置行的大小信息void SetRowSizes (const wxGridSizesInfo &sizeInfo)// 设置指定单元格的大小void SetCellSize (int row, int col, int num_rows, int num_cols)// 获取指定单元格的大小CellSpan GetCellSize (int row, int col, int *num_rows, int *num_cols) const// 获取单元格的大小wxSize     GetCellSize (const wxGridCellCoords &coords)// 推断制定列大小是否可变bool CanDragColSize (int col) const// 推断表格大小是否可变bool CanDragGridSize () const// 推断制定行大小是否可变bool CanDragRowSize (int row) const// 使指定列大小不能改变void DisableColResize (int col)// 使指定行大小不能改变void DisableRowResize (int row)// 使列大小不能改变void DisableDragColSize ()// 使表格大小不能改变void DisableDragGridSize ()// 使行大小不能改变void DisableDragRowSize ()void EnableDragColSize (bool enable=true)// 设置表格大小是否可变void EnableDragGridSize (bool enable=true)// 设置行大小是否可变void EnableDragRowSize (bool enable=true)// 获取列数int GetNumberCols () const// 获取行数int GetNumberRows () const关于边框的API:// 获取指定列的画笔virtual wxPen GetColGridLinePen (int col)// 获取默认的表格边框的画笔virtual wxPen GetDefaultGridLinePen ()// 获取表格边框的颜色wxColour GetGridLineColour () const// 获取行边框的画笔virtual wxPen GetRowGridLinePen (int row)// 表格是否有边框bool GridLinesEnabled () const// 设置表格边框的颜色void SetGridLineColour (const wxColour &colour)关于表头的API:    // 获取指定列标签(表头)的对其方式void GetColLabelAlignment (int *horiz, int *vert) const     // 获取指定列标签(表头)的文件的方向int GetColLabelTextOrientation () const// 获取制定列标签的内容wxString GetColLabelValue (int col) const     // 获取标签(表头)的背景颜色wxColour GetLabelBackgroundColour () const     // 获取标签的字体wxFont GetLabelFont () const     // 获取标签的文字颜色wxColour GetLabelTextColour () const     // 获取行标签的对齐方式void GetRowLabelAlignment (int *horiz, int *vert) const// 获取行标签的内容wxString GetRowLabelValue (int row) const// 隐藏标签void HideColLabels ()     // 隐藏行标签void HideRowLabels ()     // 设置列标签的对齐方式void SetColLabelAlignment (int horiz, int vert)// 设置列标签的文字方向void SetColLabelTextOrientation (int textOrientation)// 设置列标签的内容void SetColLabelValue (int col, const wxString &value)// 设置标签的背景颜色void SetLabelBackgroundColour (const wxColour &colour)// 设置标签的字体void SetLabelFont (const wxFont &font)// 设置标签的文字颜色void SetLabelTextColour (const wxColour &colour)// 设置行标签的对齐方式void SetRowLabelAlignment (int horiz, int vert)// 设置行标签的内容void SetRowLabelValue (int row, const wxString &value)关于表结构的API:// 追加列bool AppendCols (int numCols=1, bool updateLabels=true)// 追加行bool AppendRows (int numRows=1, bool updateLabels=true)// 删除指定列bool DeleteCols (int pos=0, int numCols=1, bool updateLabels=true)     // 删除指定行bool DeleteRows (int pos=0, int numRows=1, bool updateLabels=true)// 插入新列bool InsertCols (int pos=0, int numCols=1, bool updateLabels=true)// 插入新行bool InsertRows (int pos=0, int numRows=1, bool updateLabels=true)关于选中的API:// 清楚选中状态void ClearSelection ()// 获取选中的单元格wxGridCellCoordsArray GetSelectedCells () const// 获取选中的列wxArrayInt GetSelectedCols () const// 获取选中的行wxArrayInt     GetSelectedRows () const// 获取选中区域的背景颜色wxColour GetSelectionBackground () const// 获取选中区域的前景色wxColour GetSelectionForeground () const// 获取选中模式wxGridSelectionModes GetSelectionMode () const// 推断制定单元格是否被选中bool IsInSelection (int row, int col) const// 推断是否有选中的单元格bool IsSelection () const// 选择整个表格void SelectAll ()// 选择指定的区域void SelectBlock (int topRow, int leftCol, int bottomRow, int rightCol, bool addToSelected=false)// 选择指定的区域void SelectBlock (const wxGridCellCoords &topLeft, const wxGridCellCoords &bottomRight, bool addToSelected=false)// 选择制定的列void SelectCol (int col, bool addToSelected=false)// 选择指定的行void SelectRow (int row, bool addToSelected=false)// 设置选中后的背景颜色void SetSelectionBackground (const wxColour &c)// 设置选中后的前景色void SetSelectionForeground (const wxColour &c)// 设置选中模式void SetSelectionMode (wxGridSelectionModes selmode)关于格式的API:// 获取制定单元格的对其方式void GetCellAlignment (int row, int col, int *horiz, int *vert) const// 获取制定单元格的背景颜色wxColour GetCellBackgroundColour (int row, int col) const// 获取制定单元格的字体wxFont GetCellFont (int row, int col) const// 获取制定单元格的文字颜色wxColour GetCellTextColour (int row, int col) const// 获取指定单元格默认的对齐方式void GetDefaultCellAlignment (int *horiz, int *vert) const     // 获取单元格默认的背景色wxColour GetDefaultCellBackgroundColour () const     // 获取单元格默认的字体wxFont GetDefaultCellFont () const// 获取单元格默认的字体颜色wxColour GetDefaultCellTextColour () const// 设置指定单元格的对齐方式void SetCellAlignment (int row, int col, int horiz, int vert)// 设置指定单元格的对齐方式void SetCellAlignment (int align, int row, int col)// 设置单元格的背景颜色void SetCellBackgroundColour (int row, int col, const wxColour &colour)// 设置单元格的字体void SetCellFont (int row, int col, const wxFont &font)// 设置单元格的字体颜色void SetCellTextColour (int row, int col, const wxColour &colour)// 设置单元格的字体颜色void SetCellTextColour (const wxColour &val, int row, int col)// 设置单元格字体颜色void SetCellTextColour (const wxColour &colour)// 设置单元格默认的对齐方式void SetDefaultCellAlignment (int horiz, int vert)// 设置单元格默认的背景颜色void SetDefaultCellBackgroundColour (const wxColour &colour)// 设置单元格默认的字体void SetDefaultCellFont (const wxFont &font)// 设置单元格默认的字体颜色void SetDefaultCellTextColour (const wxColour &colour)// 使单元格处于仅仅读状态void DisableCellEditControl ()// 设置单元格的编辑状态(可编辑或不可编辑)void EnableCellEditControl (bool enable=true)// 设置表格的编辑状态(可编辑或步可编辑)void EnableEditing (bool edit)// 获取指定单元格的值wxString GetCellValue (int row, int col) const// 获取制定单元格的值wxString GetCellValue (const wxGridCellCoords &coords) const// 当前单元格是否为仅仅读bool IsCurrentCellReadOnly () const// 表格是否为可编辑的bool IsEditable () const// 指定单元格是否为仅仅读bool IsReadOnly (int row, int col) const// 设置指定单元格的值void SetCellValue (int row, int col, const wxString &s)// 设置制定单元格的值void SetCellValue (const wxGridCellCoords &coords, const wxString &s)// 设置制定单元格的值void SetCellValue (const wxString &val, int row, int col)// 设置制定单元格的仅仅读属性void SetReadOnly (int row, int col, bool isReadOnly=true)// 单元格大小自适应void AutoSize ()// 指定列标签大小自适应void AutoSizeColLabelSize (int col)// 指定列大小自适应void AutoSizeColumn (int col, bool setAsMin=true)// 设置列的大小自适应属性void AutoSizeColumns (bool setAsMin=true)// 指定行大小自适应void AutoSizeRow (int row, bool setAsMin=true)// 指定行标签大小自适应void AutoSizeRowLabelSize (int col)// 设置行的大小自适应属性void AutoSizeRows (bool setAsMin=true)// 推断指定列是否是显示的bool IsColShown (int col) const         // 推断制定行是否是显示状态bool IsRowShown (int row) const        // 设置制定列的最小宽度void SetColMinimalWidth (int col, int width)        // 隐藏制定列void HideCol (int col)// 显示指定列void ShowCol (int col)        // 设置行的最小高度void SetRowMinimalHeight (int row, int height)        // 隐藏指定行  void HideRow (int col)// 显示指定行void ShowRow (int col)        // 推断单元格大小是否可变bool CanDragCell () const        // 设置单元格大小是否可变void EnableDragCell (bool enable=true)    关于属性的API:// 刷新属性void RefreshAttr (int row, int col)// 设置指定列的属性void SetColAttr (int col, wxGridCellAttr *attr)// 设置表格外边距void SetMargins (int extraWidth, int extraHeight)// 设置指定行属性void SetRowAttr (int row, wxGridCellAttr *attr)// 获取单元格属性wxGridCellAttr * GetOrCreateCellAttr (int row, int col) const// 获取列数int GetNumberCols () const// 获取行数int GetNumberRows () const关于排序的API:// 推断排序规则是否为ASCII码bool IsSortOrderAscending () const// 设置排序列void SetSortingColumn (int col, bool ascending=true)     // 设置列的排序规则void SetColumnsOrder (const wxArrayInt &order)// 获取列的最小宽度int GetColMinimalWidth (int col) const// 获取行的最小高度int GetRowMinimalHeight (int col) const选中模式:wxGridSelectCellswxGridSelectRowswxGridSelectColumnswxGridSelectRowsOrColumns对齐方式:wxALIGN_LEFT     wxALIGN_TOP     wxALIGN_RIGHT     wxALIGN_BOTTOM     wxALIGN_CENTER_VERTICAL     wxALIGN_CENTRE_VERTICAL     wxALIGN_CENTER     wxALIGN_CENTRE   
具体解释的API介绍见:http://docs.wxwidgets.org/trunk/classwx_grid.html

3. 演示样例代码
    在此我们实现一个4*5的表格,其核心代码例如以下所看到的:   
void CreateTable(wxWindow* parent)
{char* attr[] = {"姓名", "年龄", "性别", "身高", "体重"};wxGrid *grid = new wxGrid(parent, wxID_ANY, wxPoint(0, 0), wxSize(580, 310));// 创建一个8×5的表格grid->CreateGrid(8, 5);// 设置默认的行高度grid->SetDefaultRowSize(35);// 设置默认的列宽度grid->SetDefaultColSize(100);// 设置表头的背景色grid->SetLabelBackgroundColour(0x228B22);// 设置表头的颜色grid->SetLabelTextColour(0xFFFFFF);// 设置单元格中数据的对其方式grid->SetDefaultCellAlignment(wxALIGN_CENTER, wxALIGN_CENTRE);// 设置表头for (int i = 0; i < 5; i++){grid->SetColLabelValue(i, wxString::FromUTF8(attr[i]));}// 使表格全然显示parent->Fit();
}     

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/259027.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

powerdesigner画关系图_想画好手绘,这些图你一定要画一下!

画好手绘除了对透视要深入了解掌握以及线条运用把握之外&#xff0c;还有很重要的就是要对空间物体的关系、比例、光影关系都要理解透彻。大体快可分割成多个x小体块。其实当年学习的绘画基础也是画好手绘的基础&#xff0c;画手绘依然需要去理解整体画面的空间黑白灰、物体穿插…

C#,pdf文件转换成图片文件。

本文采用Adobe Acrobat9.0的COM组件&#xff0c;将Pdf文件的每一页转换成对应的图片文件。 开发环境&#xff1a;VS2010&#xff0c;.Net Framework4.0&#xff0c;Adobe Acrobat9.0。 工程中添加COM引用&#xff1a;Adobe Acrobat 9.0 Type Library&#xff08;必须装了Adobe …

Android进程间通信

一.Linux系统进程间通信有哪些方式&#xff1f; 1.socket&#xff1b; 2.name pipe命名管道&#xff1b; 3.message queue消息队列&#xff1b; 4.singal信号量&#xff1b; 5.share memory共享内存&#xff1b; 二.Java系统的通信方式是什么&#xff1f; 1.socket; 2.name pip…

最新的一些开源face alignment及评价

dlib &#xff1a;https://github.com/davisking/dlib/tree/v18.18 评价&#xff1a;速度快&#xff0c;可商用&#xff0c;有些时候不太准确 2. CLM-framework: https://github.com/TadasBaltrusaitis/CLM-framework 评价:很准确&#xff0c;不可商用 3. Face Detection…

1048 石子归并

1048 石子归并 时间限制: 1 s 空间限制: 128000 KB 题目等级 : 黄金 Gold 题目描述 Description有n堆石子排成一列&#xff0c;每堆石子有一个重量w[i], 每次合并可以合并相邻的两堆石子&#xff0c;一次合并的代价为两堆石子的重量和w[i]w[i1]。问安排怎样的合并顺序&#xf…

internetreadfile读取数据长度为0_【完结】TensorFlow2.0 快速上手手册

大家好&#xff0c;这是专栏《TensorFlow2.0》的第五篇文章&#xff0c;我们对专栏《TensorFlow2.0》进行一个总结。我们知道全新的TensorFlow2.0 Alpha已经于2019年3月被发布&#xff0c;新版本对TensorFLow的使用方式进行了重大改进&#xff0c;为了满足各位AI人对TensorFlow…

Facial Landmark Detection(人脸特征点检测)

原文地址&#xff1a;http://www.learnopencv.com/facial-landmark-detection/#comment-2471797375 作为计算机视觉研究员&#xff0c;我们很早就开始研究人脸。人脸分析领域最广为人知的就是人脸识别&#xff08;face recognition&#xff09;.但是为了识别一幅图像中的人脸&…

cpu卡操作协议iso14443协议

http://baike.baidu.com/link?url3mef2ZMRoNuBrVLA2HpEh8xrBtzACdIi5nIDUsMyVkA8OulIXGWgswvFcTiBfh_B转载于:https://www.cnblogs.com/shuenjian901/p/3496331.html

Python 字符串的内置函数

方法描述string.capitalize()把字符串的第一个字符大写string.center(width)返回一个原字符串居中,并使用空格填充至长度 width 的新字符串string.count(str, beg0, endlen(string))返回 str 在 string 里面出现的次数&#xff0c;如果 beg 或者 end 指定则返回指定范围内 str …

Java中的Error和Exceptiond的异同点

Error和Exception的异同点&#xff1a; &#xff08;1&#xff09;Error类和Exception类都继承超类Java.lang.Throwable &#xff08;2&#xff09;Error&#xff1a;一般指与虚拟机相关的问题&#xff0c;如系统崩溃&#xff0c;内存溢出等。对于这类错误&#xff0c;仅靠程序…

python算法题_python基本算法题(一)

1、3位水仙花数计算 "3位水仙花数”是指一个三位整数&#xff0c;其各位数字的3次方和等于该数本身。 例如&#xff1a; ABC是一个“3位水仙花数”&#xff0c;则&#xff1a;A的3次方&#xff0b;B的3次方&#xff0b;C的3次方 ABC。 使用Python&#xff0c;输出所有的3…

虚拟机环境下安装ESX不能安装虚拟系统解决方案

在虚拟机环境&#xff08;ESX、workstation等&#xff09;下安装ESX或workstation等虚拟机&#xff0c;在虚拟机上再安装操作系统&#xff0c;会提示“虚拟系统不能启动&#xff0c;直到你配置了外部虚拟机&#xff08;vmware esx in a virtual machine requires the outer vir…

superviseddescent (SDM C++11实现)环境配置

今天试着用了一下SDM的C11实现&#xff0c;本来以为挺简单的&#xff0c;可是配置环境还是花了一些时间。为了给自己留下一些记忆&#xff0c;特把配置过程记录下来。 这个实现是C11的版本&#xff0c;是一个通用版本&#xff0c;里面包含了很多的功能&#xff0c;比如函数的最…

1008: University

台州ACM&#xff1a;1008: University Description 在大学里&#xff0c;非常多单词都是一词多义。偶尔在文章里还要用引申义。这困扰Redraiment非常长的时间。 他開始搜集那些单词的全部意义。他发现了一些规律&#xff0c;比如 “a”能用“e”来取代, “c”能用“f”来取代……

Android 5.1 API 22 所有sdk文件下载地址

开源中国的 IT 公司开源软件整理计划介绍 https://dl-ssl.google.com/android/repository/docs-22_r01.ziphttp://dl.google.com/android/repository/android-22_r01.ziphttps://dl-ssl.google.com/android/repository/samples-22_r05.ziphttps://dl-ssl.google.com/android/re…

python图形小游戏代码_手把手制作Python小游戏:俄罗斯方块(一)

手把手制作Python小游戏&#xff1a;俄罗斯方块1大家好&#xff0c;新手第一次写文章&#xff0c;请多多指教 A.准备工作&#xff1a; 这里我们运用的是Pygame库&#xff0c;因为Python没有内置&#xff0c;所以需要下载 如果没有pygame&#xff0c;可以到官网下载 pygame官网&…

关于Git使用的一些心得

2019独角兽企业重金招聘Python工程师标准>>> 本篇稍微记录下Git使用的一些心得。 对Git的使用&#xff0c;应该是从搭建自己的博客开始的。当时看到开源中国推荐的一篇基于码云hexo搭建自己博客的文章。所以就花了一天时间鼓捣了下博客。 顺带整理下目前能看到我写的…

Dlib机器学习库安装

昨天使用了一下dlib的人脸检测功能&#xff0c;效果出奇的好。下面给出dlib整个的安装过程和使用指导。 下载安装 我们可以从dlib的官网下载最新的版本&#xff0c;我的是dlib18.18.然后我们需要使用cmake编译dlib库和examples示例。 当然前提是你要按照好cmake和opencv。 …

struts2上传

今天在使用struts2上传的过程中无意发现,struts2上传一个文件大小为0字节的文本竟然会报错FileNotFoundException,尝试了好久也没找到答案,最后只能判断文件的大小后上传,至于文件字节为0的怎么处理就看各位了 struts2上传java源码 1 package com.jzgx.web.action;2 3 import j…

BitSet之为什么用long保存信息

BitSet内部使用long[] words来保存位信息。咋看之下并不理解原因&#xff0c;在解读set(int bitIndex)之后似乎有了一些领悟。 public void set(int bitIndex) { if (bitIndex < 0) throw new IndexOutOfBoundsException("bitIndex < 0: " bitIndex); //用来计…