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.pswp.cn/news/259027.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/259027.shtml
英文地址,請注明出處:http://en.pswp.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); //用來計…