Must be because it still keeps a reference to where it was.  And your problem is?  Are you just trying to set a default.  You're hard coding the names in.  Just hard code them in alphabetical order or sort the names first, then add to your ListView control.

On 7/28/05, BABU ABOOBACKER <[EMAIL PROTECTED]> wrote:
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






SPONSORED LINKS
Programming languages C programming language Computer programming languages
Java programming language C programming language History of computer programming language


YAHOO! GROUPS LINKS




Reply via email to