GridControl::IsBold

 

Contents

Description

Returns whether a cell's text is bold.

Syntax

bool IsBold( int nRow, int nCol )

Parameters

nRow
[input] 0-offset row index
nCol
[input] 0-offset column index

Return

true if the cell's text is bold otherwise false.

Examples

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_CONTEXTMENU(OnShowMenu)
        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);
                
                m_GridCtrl.SetSelection(flexSelectionListBox);
                m_GridCtrl.SetAllowSelection(false);

                
                //move grid control to top left
                RECT rrList;    
                rrList.top = rrList.left = GetControlGap();
                m_GridCtrl.MoveWindow(rrList);
                
                
                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 OnShowMenu(UINT nResIDCtrl, int nx, int ny)
        {
                if(IDC_GRID == nResIDCtrl)
                {
                        int nRow, nCol;
                        m_GridCtrl.GetMouseCell(nRow, nCol);
                        
                        UINT nFlags = m_GridCtrl.IsInGrid(nRow, nCol) && (nCol-m_GridCtrl.GetColOffset()>=0) && m_GridCtrl.HasRows();
                        
                        Menu menuRows;
                        menuRows.Add("MoveUp", 1, nFlags&&nRow!=m_GridCtrl.GetRowOffset()? MF_ENABLED : MF_DISABLED | MF_GRAYED);
                        menuRows.Add("MoveDown", 2, nFlags&&nRow!= m_GridCtrl.GetRows()-1? MF_ENABLED : MF_DISABLED | MF_GRAYED);
                        menuRows.Add("SetBold", 3, nFlags&&m_GridCtrl.IsBold(nRow,nCol)==0 ? MF_ENABLED : MF_DISABLED | MF_GRAYED);
                        menuRows.Add("SetItalic", 4, nFlags&&m_GridCtrl.IsItalic(nRow,nCol)==0? MF_ENABLED : MF_DISABLED | MF_GRAYED);
                        
                        int nCmd = 0;
                        menuRows.TrackPopupMenu(0, nx, ny, GetSafeHwnd(), &nCmd);
                        switch(nCmd)
                        {
                        case 1:
                                m_GridCtrl.MoveItemUp(nRow);
                                break;
                                
                        case 2:
                                m_GridCtrl.MoveItemDown(nRow);
                                break;
                                
                        case 3:
                                m_GridCtrl.SetBold(nRow,nCol,true);
                                m_GridCtrl.IsBold(nRow,nCol)?printf("It is Bold now\n"):printf("failed\n");
                                break;
                                
                        case 4:
                                m_GridCtrl.SetItalic(nRow,nCol,true);
                                m_GridCtrl.IsItalic(nRow,nCol)?printf("It is Italic now\n"):printf("failed\n");
                                break;
                                                
                        }
                }
                return TRUE;
        }
        



        
private:
        GridControl         m_GridCtrl;
};

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

Remark

See Also

GridControl::SetBold

header to Included

GridControl.h