Listcontrol problem
-
listCtrl problem: Hello I am inserting some item to list control from database. Say items are stored in database as following: A1, B1, C1, A2, B2, C2,A3,B3,C3 ------ line 1 My list control is in ascending sort order, so it displays the design as alphabetically ascending order: A1, A2, A3, B1, B2, B3, C1, C2, C3 ------ line 2 Now in list box i am selecting B1,B2,B3 and using following code:
POSITION pos = m_DesignList.GetFirstSelectedItemPosition(); // Get all the item in the listview selected 's Design ID // and assign it to the IDArray in the following loop if (pos == NULL) TRACE0("No items were selected!\n"); else while (pos) { int nItem = m_DesignList.GetNextSelectedItem(pos); if(D_EXPORT == m_ModeFlag ) // EXPORT mode { // indexArr is array filled in function onInitDialog. So it contains index value as shown in line 1 IDArray[incr++] = indexArr[nItem]; -- line 3 } m_indexCount ++; // Increase the counter of number of designs selected }
Line 3- is the main root of problem. When i select say B1,B2,B3 from the list , so as there index in the list are 3,4,5 (0 based), but actually in the recordset they are 1,4,7 instead Note: I have to keep the Listcontrol items in sorted manner. Leave your mark wherever you go -
listCtrl problem: Hello I am inserting some item to list control from database. Say items are stored in database as following: A1, B1, C1, A2, B2, C2,A3,B3,C3 ------ line 1 My list control is in ascending sort order, so it displays the design as alphabetically ascending order: A1, A2, A3, B1, B2, B3, C1, C2, C3 ------ line 2 Now in list box i am selecting B1,B2,B3 and using following code:
POSITION pos = m_DesignList.GetFirstSelectedItemPosition(); // Get all the item in the listview selected 's Design ID // and assign it to the IDArray in the following loop if (pos == NULL) TRACE0("No items were selected!\n"); else while (pos) { int nItem = m_DesignList.GetNextSelectedItem(pos); if(D_EXPORT == m_ModeFlag ) // EXPORT mode { // indexArr is array filled in function onInitDialog. So it contains index value as shown in line 1 IDArray[incr++] = indexArr[nItem]; -- line 3 } m_indexCount ++; // Increase the counter of number of designs selected }
Line 3- is the main root of problem. When i select say B1,B2,B3 from the list , so as there index in the list are 3,4,5 (0 based), but actually in the recordset they are 1,4,7 instead Note: I have to keep the Listcontrol items in sorted manner. Leave your mark wherever you go