Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. CListCtrl row selection

CListCtrl row selection

Scheduled Pinned Locked Moved C / C++ / MFC
help
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    velayudhan_raj
    wrote on last edited by
    #1

    Hi guys, I am developing a dialog based application and CListCtrl is one of its controls. I have selected the check box style for clistctrl. What i want is when user clicks a check box in ListCtrl, that row should be selected. When user selects another check box, selection should be on that row. Please help me by giving some source code. Thanks in Advance Velayudhan

    S L 2 Replies Last reply
    0
    • V velayudhan_raj

      Hi guys, I am developing a dialog based application and CListCtrl is one of its controls. I have selected the check box style for clistctrl. What i want is when user clicks a check box in ListCtrl, that row should be selected. When user selects another check box, selection should be on that row. Please help me by giving some source code. Thanks in Advance Velayudhan

      S Offline
      S Offline
      Sachinpatole
      wrote on last edited by
      #2

      Use "SetSelectionMark" member function of CListCtrl class

      V 1 Reply Last reply
      0
      • S Sachinpatole

        Use "SetSelectionMark" member function of CListCtrl class

        V Offline
        V Offline
        velayudhan_raj
        wrote on last edited by
        #3

        thanks, but my question, how do i know currently which check box has been clicked ?

        S 1 Reply Last reply
        0
        • V velayudhan_raj

          thanks, but my question, how do i know currently which check box has been clicked ?

          S Offline
          S Offline
          Sachinpatole
          wrote on last edited by
          #4

          Use "GetHotItem( )" function of CListCtrl class.

          1 Reply Last reply
          0
          • V velayudhan_raj

            Hi guys, I am developing a dialog based application and CListCtrl is one of its controls. I have selected the check box style for clistctrl. What i want is when user clicks a check box in ListCtrl, that row should be selected. When user selects another check box, selection should be on that row. Please help me by giving some source code. Thanks in Advance Velayudhan

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            Hello, here is something what can be helpful? First you have to catch the OnClick() Event, and save the previous and current selection! This is what works:

            CMyDialog::OnClickList(NMHDR* pNMHDR, LRESULT* pResult)
            {
            	// iSelectionCurrent and iSelectionOld are members from my dialog:
            	iSelectionCurrent = m_cListResults.GetSelectionMark(); // ok, take a current selection!
            	
            	if(iSelectionOld == -1)
            	{ 
            		// if my old selection is less then 0, 
            		// that means i never select something before,
            		//  ok, then save the current selection for the first time!
            		iSelectionOld = iSelectionCurrent; // here
            	}
            	else
            	{	// else, i select an item before, so is iSelectionOld >= 0!
            		m_cListResults.SetCheck(iSelectionOld, FALSE); // ok, lets uncheck the previous selection
            		iSelectionOld = iSelectionCurrent; // save the current selection!
            		// this is the same:
             		// iSelectionOld = m_cListResults.GetSelectionMark();
            	}
            
            
            	m_cListResults.SetCheck(m_cListResults.GetSelectionMark(), TRUE); // and check the new selected item(Row)
            
            	*pResult = 0;
            }
            

            regards break; -- modified at 4:54 Thursday 12th October, 2006

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups