ALXGrid Control Library

.

GridDlgApp sample

The ALXGrid Control is intended for display and change of the data which may be submitted as the table. It is realized as library on basis of MFC classes which are statically connected to the application. The library includes classes: CALXGridView for support of technology document - view, and CALXGridCtrl for use in dialogue windows. And also classes - control of cells. Since version 1.1 the library includes class CALXSplitterWnd for support of dynamic splitters.

The sample shows an opportunity of use of controls of cells, and also changes of the data in cells. Class CGridView is determined from parent class CALXGridView <gridview.htm>. In his constructor are added column (function AddCo ()) and define type control (function DefineColCtrl ()). Cells of one of column are defined as a cell containing the image (function DefineImage()).

CGridCtrl::CGridCtrl()
{
 CString strTmp;

 strTmp.LoadString(ID_COL_DEBIT);
 DefineColCtrl(AddCol(115, strTmp, 
                      ACFF_RIGHT, AHFF_CENTER, 
                      0, 0, ID_COL_DEBIT), 
               GA_EDITCTRL, WS_CHILD | ES_RIGHT);

 strTmp.LoadString(ID_COL_CREDIT);
 DefineColCtrl(AddCol(115, strTmp, 
                      ACFF_RIGHT, AHFF_CENTER, 
                      0, 0, ID_COL_CREDIT), 
               GA_EDITCTRL, WS_CHILD | ES_RIGHT);

 strTmp.LoadString(ID_COL_SALDO);
 DefineColCtrl(AddCol(120, strTmp, 
                      ACFF_RIGHT, AHFF_CENTER, 
                      0, 0, ID_COL_SALDO), 
               GA_CELLCTRL);

 //...

 SetGridRowCount(m_RowInfo.GetSize()+1);
}

Also virtual function GetCellData() which returns the data of cells necessary for display is redefined.

CELL_DATA CGridCtrl::GetCellData(int nCol, int nRow)
{
 CELL_DATA CellData = CALXGrid::GetCellData(nCol,nRow);
	
 if(nRow == GetGridRowCount()-1)
 {
  switch(GetCellCtrlID(nCol,nRow))
  {
   case ID_COL_DEBIT:
   {
    COleCurrency SumDeb(0,0);
    for(int i = 0; m_RowInfo.GetSize() > i; i++)
    SumDeb += m_RowInfo[i].m_Dedet;
    CellData.m_strText = SumDeb.Format();
    break;
   }
   case ID_COL_CREDIT:
   {
    COleCurrency SumCrd(0,0);
    for(int i = 0; m_RowInfo.GetSize() > i; i++)
     SumCrd += m_RowInfo[i].m_Credit;
    CellData.m_strText = SumCrd.Format();
    break;
   }
   case ID_COL_SALDO:
   {
    COleCurrency SumSld(0,0);
    for(int i = 0; m_RowInfo.GetSize() > i; i++)
    SumSld += m_RowInfo[i].m_Dedet - m_RowInfo[i].m_Credit;
    CellData.m_strText = SumSld.Format();
    break;
   }
  }
  return CellData;
 }

 switch(GetCellCtrlID(nCol,nRow))
 {
  case ID_COL_DEBIT:
   CellData.m_strText = m_RowInfo[nRow].m_Dedet.Format();
  break;

  case ID_COL_CREDIT:
   CellData.m_strText = m_RowInfo[nRow].m_Credit.Format();
  break;

  case ID_COL_SALDO:
   CellData.m_strText = (m_RowInfo[nRow].m_Dedet 
                      - m_RowInfo[nRow].m_Credit).Format();
  break;
 }

 return CellData;
}

The virtual function OnSaveCellData() - seved data.

BOOL CGridCtrl::OnSaveCellData(int nCol, int nRow)
{
 CALXCellCtrl* pCellCtrl = GetCellCtrl(nCol,nRow);
 if(pCellCtrl != NULL)
 {
  CELL_DATA Data = pCellCtrl->GetCellData();
  switch(GetCellCtrlID(nCol,nRow))
  {
   case ID_COL_DEBIT:
    m_RowInfo[nRow].m_Dedet.ParseCurrency(Data.m_strText);
    break;
   case ID_COL_CREDIT:
    m_RowInfo[nRow].m_Credit.ParseCurrency(Data.m_strText);
    break;
   }
   InvalidateCell(2,nRow);
   InvalidateRow(m_RowInfo.GetSize());
  }
 return TRUE;
}

Downloads

Download demo project (includes release build) - 104 Kb


Comments

  • about alxGrid ActiveX Version

    Posted by Legacy on 01/24/2003 12:00am

    Originally posted by: feifeima

    Hi Alexey Dolgachov
    Do you have the alxGrid ActiveX Version,it will be used
    in other language veriosn(such as VB) if AlxGrid_Control is
    AlxGrid Version

    Reply
  • How to set the Cell Data?

    Posted by Legacy on 05/08/2002 12:00am

    Originally posted by: First

    I don't know how to set the cell data in my programs.
    Would you like to give a sample to me?

    Reply
  • There is not possible to type In edit-ctrl some chars

    Posted by Legacy on 03/30/2002 12:00am

    Originally posted by: Sergh

    There is not possible to type In edit-ctrl next chars:
    (
    &
    $
    !


    and may be more

    Reply
  • Help in adding more columns to the table

    Posted by Legacy on 02/18/2002 12:00am

    Originally posted by: Nitin Bhatnagar

    Hi,
    I want to add more columns to the table. I modified it according to your code, but I am getting linker errors like:-

    nafxcwd.lib:- like in PreCreateWindow() etc,
    libcmtd.lib:- like functions already define
    in MSVCRT.dll

    GridCtrl.obj:- Unresolved external symbol,


    Please help me so that I can add many columns to my table.


    Thanx,
    Nitin

    Reply
  • MEMORY LEAK FIX!!!!

    Posted by Legacy on 05/31/2001 12:00am

    Originally posted by: Juan Felipe Machado

    There is a small memory leak in this GREAT code, here is the fix:
    
    

    In the function CALXGrid::CreateCellCtrl(int nCol, int nRow, DWORD dwStyle, UINT nID) do the following:

    instead of
    .
    .
    .
    switch(m_HeaderInfo.m_Cols[nCol].m_CtrlInfo.m_nType)
    {
    case GA_CELLCTRL:
    {
    CALXCellCtrl* pCellCtrl = new CALXCellCtrl;
    break;
    }
    .
    .
    .

    do

    .
    .
    .
    switch(m_HeaderInfo.m_Cols[nCol].m_CtrlInfo.m_nType)
    {
    case GA_CELLCTRL:
    {
    CALXCellCtrl* pCellCtrl1 = new CALXCellCtrl;
    pCellCtrl = pCellCtrl1;
    break;
    }
    .
    .
    .

    and thats it!!! the memory leak is fixed.


    Reply
Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Live Event Date: April 21, 2015 @ 1:00 p.m. ET / 10:00 a.m. PT For mid-sized companies, the challenge of serving people and providing better service is forcing a re-evaluation of their contact centers to improve customer experiences. While these growing enterprises are driving much of the market's innovation, they must remain nimble in how they operate, and be very responsive to customer needs. This upcoming eSeminar reveals five ways mid-size organizations can gain needed agility and examines how delivering …

  • The 2014 State of DevOps Report — based on a survey of 9,200+ people in IT operations, software development and technology management roles in 110 countries — reveals: Companies with high-performing IT organizations are twice as likely to exceed their profitability, market share and productivity goals. IT performance improves with DevOps maturity, and strongly correlates with well-known DevOps practices. Job satisfaction is the No. 1 predictor of performance against organizational …

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date