Multi colum tree / list control

Some features of CTsyslistviewex, class derived from CListCtrl:

  • sort multicolumn (See: EnableSort, SortAllItems)
  • set functions (call back) for sort order. (see AddSortCallBack)
  • draw or not draw grid lines. (See ViewGridLines)
  • attach to one or more columns of resource bitmaps. (See AttachBitmap)
  • attach to one or more cells of resource bitmaps.(See AttachBitmapCell)
  • when user select one or more lines, all width of line is hightlighted.
  • support one or more lines bold, italics or both. (See SetBoldLine)

    Some features of CTreeMultiColumnCtrl, class derived from CTsyslistviewex:

  • all features of CTsyslistviewex is supported, but sort is not yet implemented
  • support one tree in one column from list control (See: SetRootColumn).
  • support multiselect
  • user can easly input data in tree with function Fill.
    
    Sample:
    	I suppose that the tree control has 2 columns, name and description:
    If the user calls:
    
    control.Fill("Root1%Description of root1(Child1%DChild1,Child2%DChild2),Root2%3,Root3")
    
    The control will contain something like this:
      + Root1  | Description of root1
        Child1 | DChild1
        CHild2 | DChild2
      + Root2  | 3
        Root3
    
    
  • Expand and collapse of any items with keys +, -, <-, ->.
  • Recursively expands items if user press '*', one one or more items.

    Download demo project - 49KB

    Download source - 28KB

    Date Posted: 07/08/98



  • Comments

    • HELP ..!!! set and get item data

      Posted by dhanya on 02/10/2005 02:35am

      hi your control is excellent..!!! that saved me right now... then how can i set a data to the list control item so that i want to retrieve that data later ( like the SetItemData and GetItemData()) please help me thanks in advance dhanya

      Reply
    • Maybe bug under win98

      Posted by Legacy on 11/25/2002 12:00am

      Originally posted by: ken

      second, third columns attached with bitmap show text of first column.
      I create a listview with 3 columns. First column show text, and second, third show bitmap. It's OK under win2k and winxp, but under win9x, text show in secord and third column too, why?

      Reply
    • Warning - it can suck up a lot of GDIs

      Posted by Legacy on 07/01/2002 12:00am

      Originally posted by: alan

      I posted a bunch of questions in the CodeGuru forumns after discovering that this thing swamps Windows98 and Millenium after 400 or so GDI objects are created with the AttachBitmapCell() (..CTColumnBitmap)

      I had about 100 rows with about 4 bitmaps for each row.

      Someone suggested using a DIB instead of DDB. I'm not real knowledgable about these but it might be an improvement.

      Reply
    • Programmatic Selection Of List Items (Multiple )

      Posted by Legacy on 06/10/2002 12:00am

      Originally posted by: Sriram

      Hello,

      Let me appreciate your code first. It is very neat and professional.

      I ahve a question for you.
      Can i progrmmatically select specific list items?

      Let us say I want to differnetiate Group A and B due to certain conditions. Can i use SelectItem()?

      How can i do it?

      Please mail me the solution

      Thanks in Advnace
      Sriram

      Reply
    • How to use in non-diagloge application

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

      Originally posted by: Stefan

      Hello,

      I would like to implement the CMultiTreeCtrl class
      in a non-diagloge based application.

      I tried to use the Create function but this doesn't
      seem to work.

      Please let me know if anybody knows how to handle this
      problem.

      Thx.

      Reply
    • bug in multi-column tree control -

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

      Originally posted by: Konermann

      In the Methode CTreeMultiColumnCtrl::DrawCell

      1) Resoucen-Error:

      - set the &-Key by penGray:

      CPen* pOldPen = (CPen*)pDC->SelectObject(&penGray);

      - Select the pOldPen

      ...
      drawRect.left = x + 2;
      pDC->SelectObject(pOldPen);
      pDC->SelectClipRgn(NULL);
      ...

      In the CLASS CTsyslistviewex

      2) Size-Error

      - Set in the Tsyslistviewex.h:

      ...
      int m_nHeightRel;
      BOOL m_nHeightRel_aktiv;
      CMap<int,int, CTColumnBitmap*, CTColumnBitmap*>_bmpColumns;
      ...

      - set the varible m_n_HeightRel_aktiv in CTsyslistviewex::CTsyslistviewex false
      ...
      m_nHeightRel = nHeightRel;
      m_nHeightRel_aktiv = false;
      m_bSorted = false;
      ...

      - change the Methode

      void CTsyslistviewex::MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct)
      {
      if (m_nHeightRel_aktiv==false) {
      m_nHeightRel_aktiv=true;
      lpMeasureItemStruct->itemHeight += m_nHeightRel;
      }
      }

      Reply
    • ExTree

      Posted by Legacy on 10/18/2001 12:00am

      Originally posted by: Mike Philis

      Are you looking for a cool tree control?
      
      

      Check this out: http://www.exontrol.com/sg.jsp?content=products/extree

      Features include:
      ActiveX hosting, events from contained components are fired through to your program using the exact same model used in VB6 for components added at run time, data bounding, multiple columns, and more

      Mike
      www.exontrol.com

      Reply
    • Bug maybe

      Posted by Legacy on 06/22/2001 12:00am

      Originally posted by: alan

      I don't know if this is a bug or me doing something wrong. 
      
      I'm trying to set the text in the second column for child items only.

      I'm using a nested while loop which does the correct insert for all child nodes on the call m_treeCrtl.SetItemText(item, subitem, text)

      but,when the loop is done, the very FIRST item inserted has 2nd column text of the last item inserted (which is a subitem). Follow this?

      Again, I'm putting text where the check boxes are in the sample but only for the child 'nodes'. And the problem is that the first parent node has the text of the last subitem when it should have nothing.

      If I do this to clear it:
      m_treeCtrl.SetItemText(0, 1, " ");
      m_treeCtrl.RedrawWindow();

      it clears it,

      but this does not:
      for(int x = 0; x < nNumParentEntries; x++){
      nItem = m_treeCtrl.GetNextItem(x,LVNI_ALL);
      m_treeCtrl.SetItemText( x, 1, " ");
      }
      m_treeCtrl.RedrawWindow();

      The former does what I need to fix it but not sure what is happening. Sorry this is so long.

      Reply
    • Can't add data to columns in top level rows

      Posted by Legacy on 05/18/2000 12:00am

      Originally posted by: Jed

      You cannot add text to any cell, except the first column, in the top level rows in the TreeCtrlMultiColumn. Only subrows can have data beyond the first column. Is this a bug or a feature?

      Reply
    • Double click source

      Posted by Legacy on 04/23/1999 12:00am

      Originally posted by: Danny

      Hi,well I made my own solution. It is actually very simple.
      
      

      Steps for GridCtrl.cpp:
      1. In the constructor CGridCtrl::CGridCtrl(int nRows, int nCols, int nFixedRows, int nFixedCols)
      add the following code :

      // To double click on the grid an send a message to the owner of the grid
      // the owner first has to tell the grid it wants to receive the message
      // This is done by this member var which is set by a helperfunction.
      // See for the implementation CGridCtrl::OnLButtonDblClk
      m_bReturnDblClickMsg = FALSE;

      2. In function void CGridCtrl::OnLButtonDblClk(UINT nFlags, CPoint point)

      else if (m_MouseMode == MOUSE_NOTHING)
      {
      if (m_LeftClickDownCell.row >= m_nFixedRows &&
      IsValid(m_LeftClickDownCell) &&
      m_LeftClickDownCell.col >= m_nFixedCols)
      {
      OnEditCell(m_idCurrentCell.row, m_idCurrentCell.col, VK_LBUTTON);
      }
      else if (m_bListMode)
      {
      CCellID cell = GetCellFromPt(point);
      if (!IsValid(cell)) return;
      if (cell.row >= m_nFixedRows && cell.col < GetFixedColumnCount())
      OnEditCell(cell.row, cell.col, VK_LBUTTON);
      }
      // *****************
      // The following code is new
      if ( m_bReturnDblClickMsg )
      {
      CWnd *pWnd = this->GetOwner();
      if ( IsWindow(pWnd->GetSafeHwnd()) )
      pWnd->SendMessage( WM_DOUBLECLICKGRID );
      }
      // *****************
      }
      CWnd::OnLButtonDblClk(nFlags, point);
      }

      Steps for GridCtrl.h:

      1. Add a #define WM_DOUBLECLICKGRID WM_USER+1
      2. Add a public helperfunction to CGridCtrl
      void SetReturnDblClickGridMessage( BOOL bValue ) { m_bReturnDblClickMsg = bValue; }
      3. Add a protected memberbar BOOL m_bReturnDblClickMsg;


      Okay and now in you code that uses the grid:
      1. Add ON_MESSAGE(WM_DOUBLECLICKGRID, OnDblClickGrid) to your dialog's/view's BEGIN_MESSAGE_MAP
      2. Add function LRESULT CYourView::OnDblClickGrid(WPARAM wParam, LPARAM lParam)
      {
      OnModify();
      return 0L;
      }
      2. Add to header : afx_msg LRESULT OnDblClickGrid(WPARAM wParam, LPARAM lParam);
      3. And finally let the grid know you want to be able to doubleclick a row by m_Grid.SetReturnDblClickGridMessage( TRUE );

      That's all.

      Danny

      Reply
    • Loading, Please Wait ...

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

    Top White Papers and Webcasts

    • IBM Worklight is a mobile application development platform that lets you extend your business to mobile devices. It is designed to provide an open, comprehensive platform to build, run and manage HTML5, hybrid and native mobile apps.

    • Today's "average" business in general is ever more reliant on technology and the Internet. Mobility is the most often cited business trend that has transformed the way many of us work and communicate. From an IT security perspective, this means that protection methods and tools from even a few years ago are rapidly becoming "unfit for purpose." This guide provides crucial facts to assist you in building a robust business case, meeting the demands of your business, and protecting against threats now and in the …

    Most Popular Programming Stories

    More for Developers

    Latest Developer Headlines

    RSS Feeds