GridControl

 

Name

GridControl

Remark

The GridControl class is used to create and manage grid control.

Hierarchy

Examples

This section describes how to open a dialog with grid control in Origin C. The examples in this section will use an existing grid dialog resource DLL that gets installed with Origin C's Developer Kit. The DLL can be found in this zip file, under \Dialog Builder\GridDLG sub-folder.

#include <..\Originlab\DialogEx.h>
#include "GridDLGRes.h"// resource DLL header

class GridCtrlDLG : public ResizeDialog
{
public:
        GridCtrlDLG() : ResizeDialog(IDD_GRID_DLG, "GridDLG")
        {
        }

        int DoModal(HWND hParent = NULL)
        {
                InitMsgMap();
                int nRet = ResizeDialog::DoModal(hParent);
                return nRet;
        }

protected:
///----------------- Message Map ----------------
        EVENTS_BEGIN
                ON_INIT(OnInitDialog)
                ON_SIZE(OnDlgResize)
                ON_GETMINMAXINFO(OnMinMaxInfo)
                ON_OK(OnOK)
        EVENTS_END
///----------------------------------------------
        
        BOOL OnInitDialog()
        {
                ResizeDialog::OnInitDialog(0, "Grid Dialog");
                
                //initialize grid control
                m_GridCtrl.Init(IDC_GRID, *this);
                m_GridCtrl.SetupRowsCols( 1, 0, 5, 1 );
                
                vector<string> vsItems = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
                m_GridCtrl.CheckExpandRows( vsItems.GetSize()- 1 );
                m_GridCtrl.SetCells(vsItems, 0);

                //move grid control to top left
                RECT rrList;    
                rrList.top = rrList.left = GetControlGap();
                m_GridCtrl.MoveWindow(rrList);
                
                GetItem(IDOK).Text = "Test";//for example codes
                
                SetInitReady();
                return TRUE;
        }     

        BOOL OnDlgResize(int nType, int cx, int cy)
        {
                if(!IsInitReady())
                        return TRUE;          
                
                uint nButtonIDs[] = {IDOK, 0};
                ArrangeMainItemAndControls(nButtonIDs, IDC_GRID, NULL, false);
                return TRUE;
                
        }
        
        BOOL OnOK()
        {
                doExample();
                
                return FALSE;
        }
        
private:
        void doExample()
        {
        }
        
private:
        GridControl         m_GridCtrl;
};

bool OpenGridDLG()    
{
        GridCtrlDLG myDlg;
        myDlg.DoModal( GetWindow() );
        return true;
}

header to Include

GridControl.h

Reference

Members

Name Brief Example
AddCol Add columns Examples
AddOneRow Add one row Examples
CheckConvertCol Convert from actual grid index into 0 offset column index, option to expand as well. Examples
CheckConvertRow Convert from actual grid index into 0 offset row index, option to expand as well. Examples
CheckExpandRows Checks and add rows if there're not enough rows. Examples
ClearAll Remove all non-fixed rows. Examples
DeleteCol Removes one column. Examples
DeleteRow Removes one non-fixed row. Examples
EditCell Activates edit mode. Examples
FindCell Convert a screen-coordinates position to grid control's 0-offset row/column index. Examples
FindRow Returns the index of a row that contains a specified string. Examples
GetCellColor Gets color from a cell. Examples
GetCellData Gets a variant attached to the cell. Examples
GetCellDoubleData Gets a double data attached to the cell. Examples
GetCellRect Gets bounding box of a cell. Examples
GetCell Gets cell text. Examples
GetCheck Gets the state of the cell's check box. Examples
GetColAlignment Gets the alignment of the given column Examples
GetColDataType Returns the data type for the column. Examples
GetColOffset Gets the number of fixed columns. Examples
GetColValues Gets one column of cells' text. Examples
GetColWidth Gets the width of the specified column in twips. Examples
GetColsShow Returns visible columns' indexes. Examples
GetCols Gets the number of columns Examples
GetDraggedCell Gets the dragged cell's original position. Examples
GetDropCell Gets drop cell's position. Examples
GetFixedAlignment Gets the alignment for the fixed rows in a column. Examples
GetHiddenCols Gets all columns' hidden property Examples
GetIsColHidden Gets whether a column is hidden Examples
GetIsRowHidden Gets whether a row is hidden Examples
GetIsSelected Returns whether a row is selected Examples
GetIsSubtotal Returns whether a row contains subtotals Examples
GetMouseCell Returns the 0-offset row/column index under the mouse pointer. Examples
GetMousePixel Converts the given twips X/Y to screen-coordinates position and returns the 0-offset row/column index under the mouse pointer. Examples
GetNumCols Gets the number of scrollable columns. Examples
GetNumRows Gets the number of scrollable rows. Examples
GetRowData Gets a user-defined variant associated with the given row. Examples
GetRowHeight Gets the height of the specified row in twips. Examples
GetRowOffset Gets the number of fixed rows. Examples
GetRowOutlineLevel Returns the outline level for a subtotal row. Examples
GetRowRange Gets grid control's non-fixed row range. Examples
GetRowValues Gets one row of cells' text. Examples
GetRowsHide Returns each non-fixed row's hidden/displayed property. Examples
GetRowsShow Returns visible rows' indexes. Examples
GetRows Gets the number of rows Examples
GetSelCell Gets selected cell's screen-coordinates position and row/column index. Examples
GetSelectedRow Gets the position of a selected row Examples
GetTextMatrix Gets the contents of a cell Examples
GetVsFlexAlignment Gets the vertical alignment setting from PictureAlignmentSettings. Examples
GridControl Constructor.
HasRows Check if the grid has any row Examples
HideCol Hides or displays the given column. Examples
HideRow Hides or displays the given row. Examples
Init Initialize the class object with control id and dialog Examples
InsertCol Insert one column at selected column, or specified position. Examples
InsertRow Insert one row at selected row, or add one row Examples
IsAllowDragCell Returns whether to allow to drag cell Examples
IsAllowDragImage Returns whether to show drag image Examples
IsBold Returns whether a cell's text is bold. Examples
IsColheadingRow Returns whether a row is fixed row. Examples
IsColHidden Returns whether a column is hidden. Examples
IsEnable Returns whether the grid control can respond to user-generated events. Examples
IsInGrid Returns whether the given row/column index is valid in grid control. Examples
IsItalic Returns whether a cell's text is italic. Examples
IsMergeRow Gets whether a row will have its cells merged. Examples
IsMouseOnheader Gets whether the mouse pointer is at fixed row/column Examples
IsRowHidden Returns whether a row is hidden. Examples
MoveItemDown Move given row down Examples
MoveItemUp Move given row up Examples
SelCell Selects a cell. Examples
SetAllowSelection Sets whether the user can select ranges of cells with the mouse and keyboard. Examples
SetAlternateRowColors Sets the background color for alternate rows. Examples
SetBold Sets given cell's text bold. Examples
SetCellBitmap Sets bitmap to given cell. Examples
SetCellColor Sets color to a cell. Examples
SetCellComboList Sets the editor to be used when editing a cell. Examples
SetCellData Sets a double data attached to the cell. Examples
SetCellIcon Sets icon to given cell. Examples
SetCellPicture Sets picture to given cell. Examples
SetCellProperty Sets cell(s) properties. Examples
SetCells Set one row/column of cells' text. Examples
SetCell Set one cell's text. Examples
SetCheck Sets the state of the cell's check box. Examples
SetColAlignment Sets the alignment of the column. Examples
SetColComboList Sets the drop-down list to given column Examples
SetColDataType Sets the data type for the column. Examples
SetColDotButtonIcon Sets icon to given column. Examples
SetColheader Assigns column header Examples
SetColheading Sets the heading of the column. Examples
SetColHighlight Sets whether a column can be highlighted. Examples
SetColPosition Moves a given column to a new position. Examples
SetColValues Sets one column text. Examples
SetColWidth Sets the width of the specified column in twips. Examples
SetCols Sets the number of columns Examples
SetDragCell Sets whether to allow to drag cell Examples
SetDragImage Sets whether to show drag image Examples
SetEditable Sets whether the control allows in-cell editing. Examples
SetEnable Enables or disables the grid control to respond to user-generated events. Examples
SetExplorerBar Sets whether column headers are used to sort and/or move columns. Examples
SetExtendLastCol Sets whether the last column should be adjusted to fit the grid control's width. Examples
SetFinishEditing Finishes any pending edits and returns the grid to browse mode. Examples
SetFixedAlignment Sets the alignment for the fixed rows in a column. Examples
SetFixedColAlignment Sets the alignment for the fixed rows in one or all scrollable columns. Examples
SetFixedRowValues Sets text to fixed row. Examples
SetGridFont Sets the name of the font. Examples
SetGridLines Sets the type of lines to be drawn between non-fixed cells. Examples
SetHiddenCols Sets all columns' hidden property Examples
SetIcon Sets icon with selected effect to given cell Examples
SetIsColHidden Sets whether a column is hidden Examples
SetIsRowHidden Sets whether a row is hidden Examples
SetIsSelected Sets whether a row is selected Examples
SetIsSubtotal Sets whether a row contains subtotals Examples
SetItalic Sets given cell's text italic. Examples
SetMergeCol Sets whether a column will have its cells merged. Examples
SetMergeRow Sets whether a row will have its cells merged. Examples
SetOutlineBar Sets the type of outline bar that should be displayed. Examples
SetOwnerDraw Sets whether and when the control will fire the DrawCell event. Examples
SetRowColor Sets color to a row. Examples
SetRowData Sets a user-defined variant associated with the given row. Examples
SetRowheaderValues Sets the heading of all the scrollable rows. Examples
SetRowheading Sets the heading of the row. Examples
SetRowHeight Sets the height of the specified row in twips. Examples
SetRowOutlineLevel Sets the outline level for a subtotal row. Examples
SetRowPosition Move given row to the specified position Examples
SetRowValues Sets one row text. Examples
SetRowsIsSelected Sets whether a range of rows are selected Examples
SetRows Sets the number of rows Examples
SetScrollBars Sets whether the control will display horizontal or vertical scroll bars. Examples
SetSelection Sets whether the control will select cells in a free range, by row, by column, or like a listbox. Examples
SetTableValue Sets text to grid control's non-fixed area Examples
SetTextMatrix Sets the contents of a cell Examples
SetupRowsCols Sets the number of rows, columns, fixed rows and fixed columns. Examples
ShowAlternateGroups Sets groups of rows with alternate colors. Examples
ShowCols Hides or displays non-fixed columns. Examples
ShowRows Hides or displays non-fixed rows. Examples
SortCol Sort a column Examples
~GridControl Destructor.