IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

C++/CLI Discussion :

Fonctionnement de CGridListCtrlEx


Sujet :

C++/CLI

Mode arborescent

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre averti
    Profil pro
    Inscrit en
    Avril 2010
    Messages
    40
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2010
    Messages : 40
    Par défaut Fonctionnement de CGridListCtrlEx
    Bonjour

    Voila je voulais utilisé le code CGridListCtrlEx pour afficher mon tableau malheureusement je n'arrive même pas à ajouter une colonne dans le code de démo

    hCGridListCtrlEx

    J'ai modifié deux fonctions

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    CString GetCellText(int col, bool title) const
        {
            switch(col)
            {
            case 0: { static const CString title0(_T("Country")); return title ? title0 : m_Country; }
            case 1: { static const CString title1(_T("Capital")); return title ? title1 : m_City; }
            case 2: { static const CString title2(_T("European Championship")); return title ? title2 : m_YearWon.GetStatus()==m_YearWon.valid ? m_YearWon.Format() : CString(); }
            case 3: { static const CString title3(_T("Wiki")); return title ? title3 : m_YearWon.GetStatus()==m_YearWon.valid ? m_YearWon.Format(_T("%Y")) : CString(); }
            
            //Premiere modification que j'ai faite
            case 4: { static const CString title4(_T("AAAA")); return title ? title4 : m_Country; }
    
    
            default:{ static const CString emptyStr; return emptyStr; }
            }
        }
    Et

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    BOOL CGridListCtrlExDlg::OnInitDialog()
    {
    	CDialog::OnInitDialog();
    
    	// Add "About..." menu item to system menu.
    
    	// IDM_ABOUTBOX must be in the system command range.
    	ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
    	ASSERT(IDM_ABOUTBOX < 0xF000);
    
    	CMenu* pSysMenu = GetSystemMenu(FALSE);
    	if (pSysMenu != NULL)
    	{
    		CString strAboutMenu;
    		strAboutMenu.LoadString(IDS_ABOUTBOX);
    		if (!strAboutMenu.IsEmpty())
    		{
    			pSysMenu->AppendMenu(MF_SEPARATOR);
    			pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
    		}
    	}
    
    	// Set the icon for this dialog.  The framework does this automatically
    	//  when the application's main window is not a dialog
    	SetIcon(m_hIcon, TRUE);			// Set big icon
    	SetIcon(m_hIcon, FALSE);		// Set small icon
    
    	// TODO: Add extra initialization here
    
    	// Create and attach image list
    	m_ImageList.Create(16, 16, ILC_COLOR16 | ILC_MASK, 1, 0);
    	m_ImageList.Add(AfxGetApp()->LoadIcon(IDI_FLGDEN));
    	m_ImageList.Add(AfxGetApp()->LoadIcon(IDI_FLGGERM));
    	m_ImageList.Add(AfxGetApp()->LoadIcon(IDI_FLGFRAN));
    	m_ImageList.Add(AfxGetApp()->LoadIcon(IDI_FLGGREEC));
    	m_ImageList.Add(AfxGetApp()->LoadIcon(IDI_FLGSWED));
    	m_ImageList.Add(AfxGetApp()->LoadIcon(IDI_FLGSPAIN));
    	int nStateImageIdx = CGridColumnTraitDateTime::AppendStateImages(m_ListCtrl, m_ImageList);	// Add checkboxes
    	m_ListCtrl.SetImageList(&m_ImageList, LVSIL_SMALL);
    	
    	// Give better margin to editors
    	m_ListCtrl.SetCellMargin(1.2);
    	CGridRowTraitXP* pRowTrait = new CGridRowTraitXP;
    	m_ListCtrl.SetDefaultRowTrait(pRowTrait);
    
    	// Create Columns
    	m_ListCtrl.InsertHiddenLabelColumn();	// Requires one never uses column 0
    
    	for(int col = 0; col < m_DataModel.GetColCount() ; ++col)
    	{
    		const CString& title = m_DataModel.GetColTitle(col);
    		CGridColumnTrait* pTrait = NULL;
    		if (col==0)	// Country
    		{
    			CGridColumnTraitCombo* pComboTrait = new CGridColumnTraitCombo;
    			const vector<CString>& countries = m_DataModel.GetCountries();
    			for(size_t i=0; i < countries.size() ; ++i)
    				pComboTrait->AddItem((DWORD_PTR)i, countries[i]);
    			pTrait = pComboTrait;
    		}
    		if (col==1)	// City
    		{
    			pTrait = new CGridColumnTraitEdit;
    		}
    		if (col==2)	// Year won
    		{
    			CGridColumnTraitDateTime* pDateTimeTrait = new CGridColumnTraitDateTime;
    			pDateTimeTrait->AddImageIndex(nStateImageIdx, _T(""), false);		// Unchecked (and not editable)
    			pDateTimeTrait->AddImageIndex(nStateImageIdx+1, COleDateTime(1970,1,1,0,0,0).Format(), true);	// Checked (and editable)
    			pDateTimeTrait->SetToggleSelection(true);
    			pTrait = pDateTimeTrait;
    		}
    		if (col==3)	// Year won
    		{
    			CGridColumnTraitHyperLink* pHyperLinkTrait = new CGridColumnTraitHyperLink;
    			pHyperLinkTrait->SetShellFilePrefix(_T("http://en.wikipedia.org/wiki/UEFA_Euro_"));
    			pTrait = pHyperLinkTrait;
    		}
    // Deuxieme partie ajouté.
    
    		if (col==4)
    		{
    			pTrait = new CGridColumnTraitEdit;
    		}
    
    
    		m_ListCtrl.InsertColumnTrait(col+1, title, LVCFMT_LEFT, 100, col, pTrait);
    	}
    
    	// Insert data into list-control by copying from datamodel
    	int nItem = 0;
    	for(size_t rowId = 0; rowId < m_DataModel.GetRowIds() ; ++rowId)
    	{
    		nItem = m_ListCtrl.InsertItem(++nItem, m_DataModel.GetCellText(rowId,0));
    		m_ListCtrl.SetItemData(nItem, rowId);
    		for(int col = 0; col < m_DataModel.GetColCount() ; ++col)
    		{
    			int nCellCol = col+1;	// +1 because of hidden column
    			const CString& strCellText = m_DataModel.GetCellText(rowId, col);
    			m_ListCtrl.SetItemText(nItem, nCellCol, strCellText);
    			if (nCellCol==3)
    			{
    				if (strCellText==_T(""))
    					m_ListCtrl.SetCellImage(nItem, nCellCol, nStateImageIdx);	// unchecked
    				else
    					m_ListCtrl.SetCellImage(nItem, nCellCol, nStateImageIdx+1);	// checked
    			}
    		}
    		m_ListCtrl.SetCellImage(nItem, 1, nItem); // Assign flag-images
    	}
    
    	CViewConfigSectionWinApp* pColumnProfile = new CViewConfigSectionWinApp(_T("Sample List"));
    	pColumnProfile->AddProfile(_T("Default"));
    	pColumnProfile->AddProfile(_T("Special"));
    	m_ListCtrl.SetupColumnConfig(pColumnProfile);
    
    	return TRUE;  // return TRUE  unless you set the focus to a control
    }
    Je n'arrive pas à afficher le 5ieme colonne je ne sais plus quoi faire pour réussir à le faire

    Quelqu'un a une idée de comment faire, je dois avoir en tout une douzaine de colonne pour afficher des données de fichiers bmp.

    Merci, cordialement.
    Fichiers attachés Fichiers attachés

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Réponses: 3
    Dernier message: 16/06/2003, 16h51
  2. Réponses: 5
    Dernier message: 14/05/2003, 14h51
  3. [Turbo Pascal] TP7 fonctionne en QWERTY
    Par callahan dans le forum Turbo Pascal
    Réponses: 9
    Dernier message: 08/02/2003, 21h49
  4. Prb de fonctionnement dans SaveDialog avecInitialDir
    Par boyerf dans le forum Composants VCL
    Réponses: 4
    Dernier message: 12/12/2002, 21h46
  5. ca ne fonctionne pas (generateur auto-incrémentant)
    Par tripper.dim dans le forum SQL
    Réponses: 7
    Dernier message: 26/11/2002, 00h10

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo