Wxwidgets's Wxgrid control

Source: Internet
Author: User
Tags wxwidgets

1. Introduction

The Wxgrid control is a grid control that is built into the Wxwidgets interface library. Typically used to display tabular data. The control has powerful features that developers can customize to suit their needs.

2. Common APIs
     Constructor: Wxgrid () Wxgrid (Wxwindow *parent, wxwindowid ID, const wxpoint &pos=wxdefaultposition, cons                         T wxsize &size=wxdefaultsize, long style=wxwants_chars, const wxstring &NAME=WXGRIDNAMESTR) CREATE TABLE API://Create an empty table bool Create (Wxwindow *parent, wxwindowid ID, const wxpoint &pos=wxdefaultpositi On, const wxsize &size=wxdefaultsize, long style=wxwants_chars, const wxstring &NAME=WXGRIDNAMESTR)//Create a Specify the row, make the column table bool Creategrid (int numrows, int numcols, wxgridselectionmodes selmode=wxgridselectcells) off API for Size://Gets the height of the column label int getcollabelsize () const//Gets the width of the specified column int getcolsize (int col) const//Gets the default column label width int getdefaultcollabelsize () const//Gets the default column width int getdefaultcol Size () const//Gets the default row label width int getdefaultrowlabelsize () const//Gets the default row height int getdefaultrows Ize () const//ReceivedThe width of the row label int getrowlabelsize () const//Gets the height of the specified row int getrowsize (int row) const//sets the width of the specified column        void setcolsize (int col, int width)//Set column label height void setcollabelsize (int height)//Set Default column width void setdefaultcolsize (int width, bool resizeexistingcols=false)//set default row height void Setdefaultrowsize (        int height, bool resizeexistingrows=false)//Set row label width void setrowlabelsize (int width)//Set the height of the specified row void setrowsize (int row, int height)//Gets the size of the column information Wxgridsizesinfo getcolsizes () const//Fetch row of large Small information Wxgridsizesinfo getrowsizes () const//Set column size information void setcolsizes (const wxgridsizesinfo &siz Einfo)//Set the size of the row information void setrowsizes (const wxgridsizesinfo &sizeinfo)//Set the size of the specified cell void S etcellsize (int row, int col, int num_rows, int num_cols)//Gets the size of the specified cell CellSpan getcellsize (int row, int c OL, int *num_rows, int *Num_cols) const//Gets the size of the cell wxsize getcellsize (const wxgridcellcoords &coords)//Determines if the column size can be variable bool candragcolsize (int col) const//Determine if the table size is variable bool Candraggridsize () const//Determine if the row size is set variable bool candragrowsize (int row) const//Make specified column size cannot change void disablecolresize (int col)//make specified row size        Cannot change void disablerowresize (int row)//Make column size cannot change void disabledragcolsize ()//Make Table size unchanged void Disabledraggridsize ()//makes the row size cannot be changed by void Disabledragrowsize () void enabledragcolsize (bool Ena Ble=true)//Set whether the table size is variable void enabledraggridsize (bool enable=true)//Set row size is variable void Enabledra Growsize (bool enable=true)//Get the number of columns int getnumbercols () const//Get row number int getnumberrows () CO        NST API for Borders://Get the brush for the specified column virtual wxpen getcolgridlinepen (int col)//Get the default table border brush Virtual Wxpen GetdefauLtgridlinepen ()//Get the color of the table border Wxcolour getgridlinecolour () const//Get the line border brush virtual Wxpen Ge Trowgridlinepen (int row)//table has border bool gridlinesenabled () const//Set table border color void setgridl Inecolour (const Wxcolour &colour) API for Table headers://Gets the specified column label (header) on its way to void getcollabelalignmen T (int *horiz, int *vert) const//Gets the direction of the file for the specified column label (header) int getcollabeltextorientation () const// Gets the contents of the column label wxstring getcollabelvalue (int col) const//Gets the background color of the label (table header) Wxcolour Getlabelbackgroun Dcolour () const//Gets the label's font Wxfont getlabelfont () const//Gets the label's text color Wxcolour Getla Beltextcolour () const//Get Line label alignment void getrowlabelalignment (int *horiz, int *vert) const//         Gets the contents of the row label wxstring getrowlabelvalue (int row) const//Hide label void hidecollabels ()//Hide Row label void HiderowlabeLS ()//Set the alignment of the column label void setcollabelalignment (int horiz, int vert)//Set the text direction of the column label void Se tcollabeltextorientation (int textorientation)//Set the contents of the column label void Setcollabelvalue (int col, const wxstring &A Mp;value)//Set label background color void Setlabelbackgroundcolour (const wxcolour &colour)//Set Label Font V        OID Setlabelfont (const wxfont &font)//Set label text color void setlabeltextcolour (const wxcolour &colour) Set the alignment of row labels void setrowlabelalignment (int horiz, int vert)//Set the contents of the row label void Setrowlabelvalu E (int row, const wxstring &value) API for Table structure://Append column bool Appendcols (int numcols=1, BOOL upd atelabels=true)//Append line bool appendrows (int numrows=1, BOOL updatelabels=true)//delete specified column bool D Eletecols (int pos=0, int numcols=1, BOOL updatelabels=true)//delete specified line bool DeleteRows (int pos=0, int n Umrows=1, BOOL Updatelabels=true)//Insert new column bool Insertcols (int pos=0, int numcols=1, BOOL updatelabels=true)//Insert new row B Ool insertrows (int pos=0, int numrows=1, bool updatelabels=true) about the selected API://clear check state void clears Election ()//Gets the selected cell Wxgridcellcoordsarray getselectedcells () const//Gets the selected column Wxarrayint G Etselectedcols () const//Gets the selected row Wxarrayint getselectedrows () const//Gets the background color of the selected area Wxcol        Our Getselectionbackground () const//Gets the foreground color of the selected area Wxcolour getselectionforeground () const//Get Check mode Wxgridselectionmodes Getselectionmode () const//Determine if the setting cell is selected bool Isinselection (int row, int col)        Const//Determine if there is a selected cell bool Isselection () const//Select the entire table void SelectAll ()//select the specified area        void Selectblock (int toprow, int leftcol, int bottomrow, int rightcol, BOOL addtoselected=false)//select specified area void Selectblock(const wxgridcellcoords &topleft, const wxgridcellcoords &bottomright, BOOL addtoselected=false)//Select the established column void Selectcol (int col, bool addtoselected=false)//Select the specified row void selectrow (int row, bool Addtoselec  Ted=false)//Set the selected background color void setselectionbackground (const wxcolour &C)//set foreground color void after selection Setselectionforeground (const wxcolour &C)//Set check mode void Setselectionmode (Wxgridselectionmodes selmod e) about the format of the API://Get the method of making the cell on its way void getcellalignment (int row, int col, int *horiz, int *vert) cons T//Gets the background color of the developing cell wxcolour getcellbackgroundcolour (int row, int col) const//Gets the font that is making the cell WXFO        NT Getcellfont (int row, int col) const//Gets the text color of the Set cell wxcolour getcelltextcolour (int row, int col) const        Gets the default alignment of the specified cell void getdefaultcellalignment (int *horiz, int *vert) const//Get cell default background color Wxcolour GetdefaultceLlbackgroundcolour () const//Get cell default font wxfont getdefaultcellfont () const//Get cell default font color Wxcolour getdefaultcelltextcolour () const//Set the alignment of the specified cell void setcellalignment (int row, int col, int        Horiz, int vert)//Set the alignment of the specified cell void setcellalignment (int align, int row, int col)//Set cell background color void Setcellbackgroundcolour (int row, int col, const wxcolour &colour)//Set the cell's font void Setcellfon T (int row, int col, const wxfont &font)//Set the font color of the cell void setcelltextcolour (int row, int col, const W        Xcolour &colour)//Set the font color of the cell void Setcelltextcolour (const wxcolour &val, int row, int col) Set cell font color void setcelltextcolour (const wxcolour &colour)//Set cell default alignment void Setdefaultcell Alignment (int horiz, int vert)//Set cell default background color void Setdefaultcellbackgroundcolour (const wxcolour &col Our)//Set cell default Wordbody void Setdefaultcellfont (const wxfont &font)//Set cell default font color void Setdefaultcelltextcolour (con        St Wxcolour &colour)//Make cell in read-only state void Disablecelleditcontrol ()//Set cell edit state (editable or not editable) void Enablecelleditcontrol (bool enable=true)//Set the editing state of a table (editable or step editable) void enableediting (bool edit)/ /Gets the value of the specified cell wxstring getcellvalue (int row, int col) const//Gets the value of the developing cell wxstring Getcellvalue (const        Wxgridcellcoords &coords) const//Current cell is read-only bool Iscurrentcellreadonly () const//table is editable        BOOL Iseditable () const//Specifies whether the cell is read-only bool IsReadOnly (int row, int col) const//sets the value of the specified cell void Setcellvalue (int row, int col, const wxstring &s)//sets the value of the Set cell void Setcellvalue (const Wxgrid Cellcoords &coords, const wxstring &s)//Set the value of the setting cell void Setcellvalue (const wxstring &val, int row, int col)//Set the read-only property of the development cell void setreadonly (int row, int col, bool isreadonly=true)//Cell size adaptive void AutoSize () Specify column label size adaptive void autosizecollabelsize (int col)//Specify column size adaptive void autosizecolumn (int col, Boo L setasmin=true)//Set the size of the column adaptive Property void Autosizecolumns (bool setasmin=true)//Specify Row size adaptive void Aut Osizerow (int row, bool setasmin=true)//Specify row label size adaptive void autosizerowlabelsize (int col)//Set Row Size adaptive                 property void Autosizerows (bool setasmin=true)//Determines whether the specified column is displayed as bool Iscolshown (int col) const Determines whether the line is displayed state bool Isrowshown (int row) const//sets the minimum width of the set column void Setcolminimalwidth (in                T col, int width)//Hide make column void hidecol (int col)//display specified column void showcol (int col)  Sets the minimum height of the row void setrowminimalheight (int row, int height)//hides the specified row void Hiderow (int col)//display meansFixed row void showrow (int col)//Determine if cell size is variable bool Candragcell () const//Set cell size is No variable void Enabledragcell (bool enable=true) API for properties://Refresh property void refreshattr (int row , int col)//Set properties of the specified column void setcolattr (int col, wxgridcellattr *attr)//Set table margin void Setmarg INS (int extrawidth, int extraheight)//Set specified line property void setrowattr (int row, wxgridcellattr *attr)//Won Take cell Properties Wxgridcellattr * getorcreatecellattr (int row, int col) const//Get number of columns int getnumbercols () con ST//Get the number of rows int getnumberrows () const about Sort API://Determine if collation is ASCII code BOOL Issortorder        Ascending () const//set sort sequence void Setsortingcolumn (int col, bool ascending=true)//Set column collation void Setcolumnsorder (const wxarrayint &order)//Gets the minimum width of the column int getcolminimalwidth (int col) Const//Gets the minimum height of the row        int getrowminimalheight (int col) const Check mode: Wxgridselectcells wxgridselectrows Wxgridsel              Ectcolumns wxgridselectrowsorcolumns Alignment: Wxalign_left wxalign_top wxalign_right Wxalign_bottom wxalign_center_vertical wxalign_centre_vertical Wxalign_ce    NTER Wxalign_centre
Detailed API introduction See: Http://docs.wxwidgets.org/trunk/classwx_grid.html

3. Sample Code
Here we implement a 4*5 table whose core code is as follows:
void CreateTable (wxwindow* parent) {        char* attr[] = {"Name", "Age", "gender", "height", "weight"};        Wxgrid *grid = new Wxgrid (parent, Wxid_any, wxpoint (0, 0), wxsize (580, 310));        Create a 8x5 table        Grid->creategrid (8, 5);        Sets the default row height        grid->setdefaultrowsize (+);        Sets the default column width        grid->setdefaultcolsize (+);        Sets the background color of the header        Grid->setlabelbackgroundcolour (0x228b22);        Sets the color of the header        Grid->setlabeltextcolour (0xFFFFFF);        Sets the way in which the data in the cell is        grid->setdefaultcellalignment (Wxalign_center, wxalign_centre);        Set header for        (int i = 0; i < 5; i++)        {            Grid->setcollabelvalue (i, Wxstring::fromutf8 (Attr[i]));        }        //Make the table fully display        parent->fit ();}     

Wxwidgets's Wxgrid control

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.