Dear Friends,
 
I have expereinced a weird problem related to C# ListView control sorting.
 
In my Form's constructor i have added some list view items , then sort it ascendig oredr an dthen i tried to select the first item in the listview and expect that it will select the first item in the sorted list.
 
But surprisingly it selects the first item added to the list view !
 
But when i move the item selection cod eto Form.Load event handler or Form.Activated event handler it is working as expected !
 
Is this any bug or already documented somewhere in MSDN?  
 
Here is the code snippet.
 
  public Form1()
  {
           
   //
   // Required for Windows Form Designer support
   //
   InitializeComponent();
 
   ......................
   ......................
 
            listView1.ListViewItemSorter = new ListViewItemComparer(0,SortOrder.Ascending);
 
            this.listView1.Items.Add("India");
            this.listView1.Items.Add("France");
            this.listView1.Items.Add("America");
            this.listView1.Items.Add("Russia");
            this.listView1.Items.Add("Japan");
 
            listView1.Sort();
 
            //This doesn't select the item "America" but selects the item "India"
          // If we move this to Form.Load or Form.Activated event handler it selects teh item "America".
            listView1.Items[0].Selected = true;
}
 
Any idea ?
 
 
Regards,
Aboobacker


YAHOO! GROUPS LINKS




Reply via email to