CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 2009
    Posts
    2

    Cool Making a DataGridView table that is full of ComboBox's... possible? (Y/N)

    Here's my vision:

    Around 30 ComboBox's (let's say 6 rows and 5 columns) and they are all in a DataGridView, so I can use some of the features of the datagridview.

    I saw (accidentally) how it's possible to have checkboxes in a DataGridView, so I'm pretty certain it's possible to put a ComboBox in there (unless I'm totally wrong), but I'm not sure how.

    Whoever can answer this is a l33t h8x0r extreme. thanks!

  2. #2
    Join Date
    Apr 2005
    Posts
    41

    Resolved Re: Making a DataGridView table that is full of ComboBox's... possible? (Y/N)

    I managed to incorporate Combo Boxes in a MFC Grid Control (as written by Chris Maunder) (v2.25).

    Here's the relevant code I used:

    Code:
    #include "GridCtrl_src/GridCtrl.h"
    #include "NewCellTypes/GridCellCombo.h"
    
    
    ....
    	CGridCtrl m_Grid;
    
    ....
    	DDX_GridControl(pDX, IDC_GRID, m_Grid);
    
    ....
    
    	CStringArray options;
    	options.Add(_T("----"));
    	options.Add(_T("Option 1"));
    	options.Add(_T("Option 2"));
    	options.Add(_T("Option 3"));
    	options.Add(_T("Option 4"));
    
    	m_Grid.SetCellType(j,i, RUNTIME_CLASS(CGridCellCombo));
    	CGridCellCombo *pCell = (CGridCellCombo*) m_Grid.GetCell(j,i);
    	pCell->SetOptions(options);
    	pCell->SetStyle(CBS_DROPDOWN); //CBS_DROPDOWN, CBS_DROPDOWNLIST, CBS_SIMPLE
    I hope this helps you somehow.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured