|| | |||Browse by category|
I have a grid with a CString in column 1 and before the user is allowed to enter another string in one of the other grid rows, I want to check to make sure there are no duplicate strings in the grid. How can I do that?
A very simple solution would be to cycle through each row of the grid and compare each string, but this is very inefficient. As already explained in the previous question, StoreStyleRowCol() is an ideal override for preparing information because it is always called when a cell is changed.
I would suggest that you override StoreStyleRowCol() and check:
If this is TRUE, you could insert the string in an associative collection like CMapStringToWord. Later, when you need to check if the string is already there, you can look in the collection if the string is already there and you don't have to loop through all rows any more. This technique will improve performance significantly.