ListCtrl: maintain the slection after repopulating it...
-
Hello, INTRODUCTION: I'm using a normal CListCtrl in a dialog based app. When I update/edit a value in the ListCtrl (REPORT MODE) I validate it versus all the other values (they must follow some rules) and if some are not as they should have to be, I modify the variables that are linked to those parameters and then I re-populate ALL the ListCtrl reading those variables... NOTE: I know that this is not the best method... but it works and I have no time to improve it... moreover there are only 8 elements in the ListCtrl. :-O QUESTION: In order not to fool the user I want to be able to place the selection where it was (over the last edited item). The fact is that I can see the selection mark over the desired element, but when I press the down arrow the selection gets placed over the first element. :confused: After the edition I'm using this code now:
if (iElement == -1) iElement = this->m_ElementModificatAct.m_iItemActual; this->SetItemState(iElement, LVIS_SELECTED, LVIS_SELECTED | LVIS_FOCUSED); this->EnsureVisible(iElement, FALSE); this->SetSelectionMark(iElement);
OK, the selection mark is drawn where it should be, but when I press the down arrow I get the selection not in the next element... I get it over the first element... Could I do anything? Thank you in advance. -
Hello, INTRODUCTION: I'm using a normal CListCtrl in a dialog based app. When I update/edit a value in the ListCtrl (REPORT MODE) I validate it versus all the other values (they must follow some rules) and if some are not as they should have to be, I modify the variables that are linked to those parameters and then I re-populate ALL the ListCtrl reading those variables... NOTE: I know that this is not the best method... but it works and I have no time to improve it... moreover there are only 8 elements in the ListCtrl. :-O QUESTION: In order not to fool the user I want to be able to place the selection where it was (over the last edited item). The fact is that I can see the selection mark over the desired element, but when I press the down arrow the selection gets placed over the first element. :confused: After the edition I'm using this code now:
if (iElement == -1) iElement = this->m_ElementModificatAct.m_iItemActual; this->SetItemState(iElement, LVIS_SELECTED, LVIS_SELECTED | LVIS_FOCUSED); this->EnsureVisible(iElement, FALSE); this->SetSelectionMark(iElement);
OK, the selection mark is drawn where it should be, but when I press the down arrow I get the selection not in the next element... I get it over the first element... Could I do anything? Thank you in advance.Funny I just solved this after posting a similar question. change this->SetItemState(iElement, LVIS_SELECTED, LVIS_SELECTED | LVIS_FOCUSED); to this->SetItemState(iElement, LVIS_SELECTED**| LVIS_FOCUSED**, LVIS_SELECTED | LVIS_FOCUSED); Dave Huff Igor would you give me a hand with the bags? Certainly - you take the blonde and I'll take the one in the turban!
-
Funny I just solved this after posting a similar question. change this->SetItemState(iElement, LVIS_SELECTED, LVIS_SELECTED | LVIS_FOCUSED); to this->SetItemState(iElement, LVIS_SELECTED**| LVIS_FOCUSED**, LVIS_SELECTED | LVIS_FOCUSED); Dave Huff Igor would you give me a hand with the bags? Certainly - you take the blonde and I'll take the one in the turban!
-
Hello, INTRODUCTION: I'm using a normal CListCtrl in a dialog based app. When I update/edit a value in the ListCtrl (REPORT MODE) I validate it versus all the other values (they must follow some rules) and if some are not as they should have to be, I modify the variables that are linked to those parameters and then I re-populate ALL the ListCtrl reading those variables... NOTE: I know that this is not the best method... but it works and I have no time to improve it... moreover there are only 8 elements in the ListCtrl. :-O QUESTION: In order not to fool the user I want to be able to place the selection where it was (over the last edited item). The fact is that I can see the selection mark over the desired element, but when I press the down arrow the selection gets placed over the first element. :confused: After the edition I'm using this code now:
if (iElement == -1) iElement = this->m_ElementModificatAct.m_iItemActual; this->SetItemState(iElement, LVIS_SELECTED, LVIS_SELECTED | LVIS_FOCUSED); this->EnsureVisible(iElement, FALSE); this->SetSelectionMark(iElement);
OK, the selection mark is drawn where it should be, but when I press the down arrow I get the selection not in the next element... I get it over the first element... Could I do anything? Thank you in advance.Do you think I can use that trick in order for my list control not to deselect all items one it loses the focus ? When I press a button it deselects all items from the list... I have to select them again... JM Earth > Europe > France > Lyon