I figured out the problem i defined the CListBox in the method and was destroyed at the end of the method.